This commit is contained in:
Looly 2022-07-17 18:43:58 +08:00
parent 49e40132ac
commit 94d5889b1c
2 changed files with 8 additions and 4 deletions

View File

@ -138,7 +138,9 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa
// 直接注解
for (final Annotation annotation : annotations) {
annotationType = annotation.annotationType();
if (false == META_ANNOTATIONS.contains(annotationType)) {
if (false == META_ANNOTATIONS.contains(annotationType)
// issue#I5FQGW@Gitee跳过元注解和已经处理过的注解防止递归调用
&& false == declaredAnnotationMap.containsKey(annotationType)) {
if(test(annotation)){
declaredAnnotationMap.put(annotationType, annotation);
}
@ -157,7 +159,9 @@ public class CombinationAnnotationElement implements AnnotatedElement, Serializa
Class<? extends Annotation> annotationType;
for (final Annotation annotation : annotations) {
annotationType = annotation.annotationType();
if (false == META_ANNOTATIONS.contains(annotationType)) {
if (false == META_ANNOTATIONS.contains(annotationType)
// issue#I5FQGW@Gitee跳过元注解和已经处理过的注解防止递归调用
&& false == declaredAnnotationMap.containsKey(annotationType)) {
if(test(annotation)){
annotationMap.put(annotationType, annotation);
}

View File

@ -11,14 +11,14 @@ public class AnnotationUtilTest {
public void getCombinationAnnotationsTest(){
final Annotation[] annotations = AnnotationUtil.getAnnotations(ClassWithAnnotation.class, true);
Assert.assertNotNull(annotations);
Assert.assertEquals(3, annotations.length);
Assert.assertEquals(2, annotations.length);
}
@Test
public void getCombinationAnnotationsWithClassTest(){
final AnnotationForTest[] annotations = AnnotationUtil.getCombinationAnnotations(ClassWithAnnotation.class, AnnotationForTest.class);
Assert.assertNotNull(annotations);
Assert.assertEquals(2, annotations.length);
Assert.assertEquals(1, annotations.length);
Assert.assertEquals("测试", annotations[0].value());
}