@@ -268,30 +268,29 @@ public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> a
268
268
/**
269
269
* Perform the search algorithm for {@link #findAnnotation(Class, Class)},
270
270
* avoiding endless recursion by tracking which annotations have already
271
- * been visited.
271
+ * been <em> visited</em> .
272
272
* @param clazz the class to look for annotations on
273
273
* @param annotationType the type of annotation to look for
274
- * @param visitedAnnotations the set of annotations that have already been visited
274
+ * @param visited the set of annotations that have already been visited
275
275
* @return the annotation if found, or {@code null} if not found
276
276
*/
277
277
private static <A extends Annotation > A findAnnotation (Class <?> clazz , Class <A > annotationType ,
278
- Set <Annotation > visitedAnnotations ) {
278
+ Set <Annotation > visited ) {
279
279
Assert .notNull (clazz , "Class must not be null" );
280
280
281
281
A annotation = clazz .getAnnotation (annotationType );
282
282
if (annotation != null ) {
283
283
return annotation ;
284
284
}
285
285
for (Class <?> ifc : clazz .getInterfaces ()) {
286
- annotation = findAnnotation (ifc , annotationType , visitedAnnotations );
286
+ annotation = findAnnotation (ifc , annotationType , visited );
287
287
if (annotation != null ) {
288
288
return annotation ;
289
289
}
290
290
}
291
291
for (Annotation ann : clazz .getAnnotations ()) {
292
- if (!visitedAnnotations .contains (ann )) {
293
- visitedAnnotations .add (ann );
294
- annotation = findAnnotation (ann .annotationType (), annotationType , visitedAnnotations );
292
+ if (visited .add (ann )) {
293
+ annotation = findAnnotation (ann .annotationType (), annotationType , visited );
295
294
if (annotation != null ) {
296
295
return annotation ;
297
296
}
@@ -301,7 +300,7 @@ private static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A>
301
300
if (superclass == null || superclass .equals (Object .class )) {
302
301
return null ;
303
302
}
304
- return findAnnotation (superclass , annotationType , visitedAnnotations );
303
+ return findAnnotation (superclass , annotationType , visited );
305
304
}
306
305
307
306
/**
@@ -648,7 +647,7 @@ private A[] getValue(Annotation annotation) {
648
647
}
649
648
catch (Exception ex ) {
650
649
throw new IllegalStateException ("Unable to read value from repeating annotation container "
651
- + this .containerAnnotationType .getName (), ex );
650
+ + this .containerAnnotationType .getName (), ex );
652
651
}
653
652
}
654
653
0 commit comments