Polish contribution
See gh-33950
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -103,11 +103,10 @@ class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotP
|
||||
}
|
||||
|
||||
Class<?> beanClass = registeredBean.getBeanClass();
|
||||
Set<Class<?>> visitedClasses = new HashSet<>();
|
||||
Set<Class<?>> validatedClasses = new HashSet<>();
|
||||
Set<Class<? extends ConstraintValidator<?, ?>>> constraintValidatorClasses = new HashSet<>();
|
||||
|
||||
processAheadOfTime(beanClass, visitedClasses, validatedClasses, constraintValidatorClasses);
|
||||
processAheadOfTime(beanClass, new HashSet<>(), validatedClasses, constraintValidatorClasses);
|
||||
|
||||
if (!validatedClasses.isEmpty() || !constraintValidatorClasses.isEmpty()) {
|
||||
return new AotContribution(validatedClasses, constraintValidatorClasses);
|
||||
@@ -118,10 +117,11 @@ class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotP
|
||||
private static void processAheadOfTime(Class<?> clazz, Set<Class<?>> visitedClasses, Set<Class<?>> validatedClasses,
|
||||
Set<Class<? extends ConstraintValidator<?, ?>>> constraintValidatorClasses) {
|
||||
|
||||
Assert.notNull(validator, "Validator cannot be null");
|
||||
|
||||
if (!visitedClasses.add(clazz)) {
|
||||
return;
|
||||
}
|
||||
Assert.notNull(validator, "Validator can't be null");
|
||||
|
||||
BeanDescriptor descriptor;
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
@@ -127,7 +126,7 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
}
|
||||
|
||||
@ParameterizedTest // gh-33936
|
||||
@ValueSource(classes = {BeanWithIterable.class, BeanWithMap.class, BeanWithOptional.class})
|
||||
@ValueSource(classes = {BeanWithRecursiveIterable.class, BeanWithRecursiveMap.class, BeanWithRecursiveOptional.class})
|
||||
void shouldProcessRecursiveGenericsWithoutInfiniteRecursion(Class<?> beanClass) {
|
||||
process(beanClass);
|
||||
assertThat(this.generationContext.getRuntimeHints().reflection().typeHints()).hasSize(1);
|
||||
@@ -258,16 +257,16 @@ class BeanValidationBeanRegistrationAotProcessorTests {
|
||||
}
|
||||
}
|
||||
|
||||
static class BeanWithIterable {
|
||||
private final Iterable<BeanWithIterable> beans = Set.of();
|
||||
static class BeanWithRecursiveIterable {
|
||||
Iterable<BeanWithRecursiveIterable> iterable;
|
||||
}
|
||||
|
||||
static class BeanWithMap {
|
||||
private final Map<String, BeanWithMap> beans = Map.of();
|
||||
static class BeanWithRecursiveMap {
|
||||
Map<BeanWithRecursiveMap, BeanWithRecursiveMap> map;
|
||||
}
|
||||
|
||||
static class BeanWithOptional {
|
||||
private final Optional<BeanWithOptional> beans = Optional.empty();
|
||||
static class BeanWithRecursiveOptional {
|
||||
Optional<BeanWithRecursiveOptional> optional;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user