GH-418 - Include JSR 303 ConstraintValidator implementations in bootstrap dependency analysis.
Spring Boot configures Hibernate Validator in a way that the latter looks up the components it needs to instantiate via the Spring container. That in turn then creates prototype instances of the types requested. This means, implementations of e.g. ConstraintValidator do not need to be explicitly marked as Spring beans, but could still declare dependencies to other Spring beans. If such a dependency crosses a module boundary, we currently fail to detect that implicitly established module dependency. This is now fixed by considering ConstraintValidator implementations Spring beans implicitly in out bootstrap dependency analysis.
This commit is contained in:
@@ -589,10 +589,12 @@ public class ApplicationModule {
|
||||
Classes repositories = source.that(isSpringDataRepository());
|
||||
Classes coreComponents = source.that(not(INTERFACES).and(isComponent()));
|
||||
Classes configurationProperties = source.that(isConfigurationProperties());
|
||||
Classes jsr303Validator = source.that(isJsr303Validator());
|
||||
|
||||
return coreComponents //
|
||||
.and(repositories) //
|
||||
.and(configurationProperties) //
|
||||
.and(jsr303Validator) //
|
||||
.and(collect.getOrDefault(true, Collections.emptyList())) //
|
||||
.and(collect.getOrDefault(false, Collections.emptyList()));
|
||||
}
|
||||
|
||||
@@ -119,6 +119,10 @@ class Types {
|
||||
return isAnnotatedWith(AT_CONFIGURATION_PROPERTIES);
|
||||
}
|
||||
|
||||
static DescribedPredicate<? super JavaClass> isJsr303Validator() {
|
||||
return implement("jakarta.validation.ConstraintValidator");
|
||||
}
|
||||
|
||||
static boolean isAtBeanMethod(JavaMethod method) {
|
||||
return isAnnotatedWith(SpringTypes.AT_BEAN).test(method);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user