Fix BindingReflectionHintsRegistrar anonymous classes support
This commit ensures that giving an anonymous class for reflection hints registration does not result in a NullPointerException, since the canonical name of anonymous classes is null. Fixes gh-29657
This commit is contained in:
parent
92a6e7ddcd
commit
d601f3196a
|
@ -71,7 +71,7 @@ public class BindingReflectionHintsRegistrar {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSkipMembers(Class<?> type) {
|
private boolean shouldSkipMembers(Class<?> type) {
|
||||||
return type.getCanonicalName().startsWith("java.") || type.isArray();
|
return (type.getCanonicalName() != null && type.getCanonicalName().startsWith("java.")) || type.isArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type type) {
|
private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type type) {
|
||||||
|
|
|
@ -221,6 +221,12 @@ public class BindingReflectionHintsRegistrarTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void registerTypeForSerializationWithAnonymousClass() {
|
||||||
|
Runnable anonymousRunnable = () -> { };
|
||||||
|
bindingRegistrar.registerReflectionHints(this.hints.reflection(), anonymousRunnable.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void registerTypeForJacksonAnnotations() {
|
void registerTypeForJacksonAnnotations() {
|
||||||
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleClassWithJsonProperty.class);
|
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleClassWithJsonProperty.class);
|
||||||
|
|
Loading…
Reference in New Issue