Skip to content

Commit

Permalink
Fix empty @DefaultValue annotation test failures on Java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Oct 1, 2022
1 parent efc431b commit 75f4d9e
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -131,10 +131,6 @@ private <T> T getNewDefaultValueInstanceIfPossible(Binder.Context context, Resol
Class<T> resolved = (Class<T>) type.resolve();
Assert.state(resolved == null || isEmptyDefaultValueAllowed(resolved),
() -> "Parameter of type " + type + " must have a non-empty default value.");
T instance = create(Bindable.of(type), context);
if (instance != null) {
return instance;
}
if (resolved != null) {
if (Optional.class == resolved) {
return (T) Optional.empty();
Expand All @@ -148,9 +144,12 @@ private <T> T getNewDefaultValueInstanceIfPossible(Binder.Context context, Resol
if (resolved.isArray()) {
return (T) Array.newInstance(resolved.getComponentType(), 0);
}
return BeanUtils.instantiateClass(resolved);
}
return null;
T instance = create(Bindable.of(type), context);
if (instance != null) {
return instance;
}
return (resolved != null) ? BeanUtils.instantiateClass(resolved) : null;
}

private boolean isEmptyDefaultValueAllowed(Class<?> type) {
Expand Down

0 comments on commit 75f4d9e

Please sign in to comment.