Fix NPE in Constructor predicate

This commit fixes a NullPointerException issue in the constructor hint
predicate. Prior to this commit, a hint for a constructor was directly
looked up and dereferenced a type hint without checking if there was one
first.
This commit is contained in:
Brian Clozel
2022-06-30 18:20:38 +02:00
parent 772d801e48
commit 7a3e8bf648
2 changed files with 7 additions and 1 deletions
@@ -136,6 +136,11 @@ class ReflectionHintsPredicatesTests {
@Nested
class ReflectionOnConstructor {
@Test
void constructorIntrospectionDoesNotMatchMissingHint() {
assertPredicateDoesNotMatch(reflection.onConstructor(publicConstructor).introspect());
}
@Test
void constructorIntrospectionMatchesConstructorHint() {
runtimeHints.reflection().registerType(SampleClass.class, typeHint -> typeHint.withConstructor(Collections.emptyList(), constructorHint -> {