Avoid infinite loop in AnnotationScanner
Prior to this commit, scanning for annotations resulted in an infinite loop when using the INHERITED_ANNOTATIONS search strategy and a class filter that filters out visited classes. This commit avoids an infinite loop in AnnotationsScanner's processClassInheritedAnnotations(...) method by skipping the current level of the class hierarchy when the current source class has been filtered out. Closes gh-25429
This commit is contained in:
committed by
Sam Brannen
parent
335c3d5db6
commit
650cbeee14
@@ -499,6 +499,22 @@ class AnnotationsScannerTests {
|
||||
assertThat(result).isEqualTo("OK");
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanWithFilteredAll() {
|
||||
List<Integer> indexes = new ArrayList<>();
|
||||
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
|
||||
SearchStrategy.INHERITED_ANNOTATIONS,
|
||||
(context, aggregateIndex, source, annotations) -> {
|
||||
indexes.add(aggregateIndex);
|
||||
return "";
|
||||
},
|
||||
(context,cls)->{
|
||||
return true;
|
||||
}
|
||||
);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
|
||||
private Method methodFrom(Class<?> type) {
|
||||
return ReflectionUtils.findMethod(type, "method");
|
||||
|
||||
Reference in New Issue
Block a user