Polish BeanValidationBeanRegistrationAotProcessor[Tests]
The log message for a NoClassDefFoundError is now a DEBUG level message handled like a TypeNotPresentException and similar to the following. DEBUG: Skipping validation constraint hint inference for class org.example.CustomConstraint due to a NoClassDefFoundError for com.example.MissingType See gh-33949
This commit is contained in:
parent
9b0253e117
commit
ea3bd7ae0c
|
|
@ -131,15 +131,21 @@ class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotP
|
|||
String className = clazz.getName();
|
||||
if (KotlinDetector.isKotlinType(clazz) && ex instanceof ArrayIndexOutOfBoundsException) {
|
||||
// See https://hibernate.atlassian.net/browse/HV-1796 and https://youtrack.jetbrains.com/issue/KT-40857
|
||||
logger.warn("Skipping validation constraint hint inference for class " + className +
|
||||
" due to an ArrayIndexOutOfBoundsException at validator level");
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Skipping validation constraint hint inference for class " + className +
|
||||
" due to an ArrayIndexOutOfBoundsException at validator level");
|
||||
}
|
||||
}
|
||||
else if (ex instanceof TypeNotPresentException) {
|
||||
logger.debug("Skipping validation constraint hint inference for class " +
|
||||
className + " due to a TypeNotPresentException at validator level: " + ex.getMessage());
|
||||
else if (ex instanceof TypeNotPresentException || ex instanceof NoClassDefFoundError) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Skipping validation constraint hint inference for class %s due to a %s for %s"
|
||||
.formatted(className, ex.getClass().getSimpleName(), ex.getMessage()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.warn("Skipping validation constraint hint inference for class " + className, ex);
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Skipping validation constraint hint inference for class " + className, ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
|||
|
||||
@Test // gh-33940
|
||||
void shouldSkipConstraintWithMissingDependency() throws Exception {
|
||||
FilteringClassLoader classLoader = new FilteringClassLoader(getClass().getClassLoader());
|
||||
MissingDependencyClassLoader classLoader = new MissingDependencyClassLoader(getClass().getClassLoader());
|
||||
Class<?> beanClass = classLoader.loadClass(ConstraintWithMissingDependency.class.getName());
|
||||
process(beanClass);
|
||||
assertThat(this.generationContext.getRuntimeHints().reflection().typeHints()).isEmpty();
|
||||
|
|
@ -280,14 +280,14 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
|||
|
||||
static class ConstraintWithMissingDependency {
|
||||
|
||||
private final Filtered filtered = new Filtered();
|
||||
MissingType missingType;
|
||||
}
|
||||
|
||||
static class Filtered {}
|
||||
static class MissingType {}
|
||||
|
||||
static class FilteringClassLoader extends OverridingClassLoader {
|
||||
static class MissingDependencyClassLoader extends OverridingClassLoader {
|
||||
|
||||
FilteringClassLoader(ClassLoader parent) {
|
||||
MissingDependencyClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
|||
|
||||
@Override
|
||||
protected Class<?> loadClassForOverriding(String name) throws ClassNotFoundException {
|
||||
if (name.contains("Filtered")) {
|
||||
if (name.contains("MissingType")) {
|
||||
throw new NoClassDefFoundError(name);
|
||||
}
|
||||
return super.loadClassForOverriding(name);
|
||||
|
|
|
|||
Loading…
Reference in New Issue