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:
Sam Brannen
2024-11-27 12:35:13 +01:00
parent 9b0253e117
commit ea3bd7ae0c
2 changed files with 18 additions and 12 deletions

View File

@@ -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;
}