Catch defensively validator exceptions in AOT processing
An ArrayIndexOutOfBoundsException is thrown by Validator.getConstraintsForClass when processing Kotlin beans with extensions functions (Kotlin or Hibernate Validator bug). This commit catches those exceptions and report them as warning without the full stactrace, and report as well other ones thrown as errors with the full stracktrace. Closes gh-30037
This commit is contained in:
@@ -105,7 +105,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
|
||||
@Retention(RUNTIME)
|
||||
@Repeatable(Exists.List.class)
|
||||
private @interface Exists {
|
||||
@interface Exists {
|
||||
|
||||
String message() default "Does not exist";
|
||||
|
||||
@@ -121,7 +121,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExistsValidator implements ConstraintValidator<Exists, String> {
|
||||
static class ExistsValidator implements ConstraintValidator<Exists, String> {
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
@@ -129,7 +129,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MethodParameterLevelConstraint {
|
||||
static class MethodParameterLevelConstraint {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String hello(@Exists String name) {
|
||||
@@ -139,7 +139,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class ConstructorParameterLevelConstraint {
|
||||
static class ConstructorParameterLevelConstraint {
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -154,7 +154,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class PropertyLevelConstraint {
|
||||
static class PropertyLevelConstraint {
|
||||
|
||||
@Exists
|
||||
private String name;
|
||||
|
||||
Reference in New Issue
Block a user