Looks like migration of AnnotationUtils to use the MergedAnnotations API has introduced a regression to the public static <A extends Annotation> A findAnnotation(Method method, @Nullable Class<A> annotationType) method when finding repeatable annotations that are declared on custom composed annotations.
// Repeatable annotation
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Repeatable(Roles.class)
public @interface Role {
String value() default "";
}
// Container annotation
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Roles {
Role[] value();
}
// Custom composed annotation
@Retention(RetentionPolicy.RUNTIME)
@Role("role_a")
@Role("role_b")
public @interface MyCustomRole {
}
class MyObject {
@MyCustomRole
public void someMethod() {}
}
AnnotationUtils.findAnnotation(someMethod, Roles.class) returns null after upgrading to 5.2.0.RELEASE
I've created a sample here to better demonstrate: https://github.com/Walliee/repeatable-annotations
All 3 tests pass on 5.1.10.RELEASE but only 2 on 5.2.0.RELEASE
Affected versions: 5.2.0.RELEASE
Looks like migration of
AnnotationUtilsto use theMergedAnnotationsAPI has introduced a regression to thepublic static <A extends Annotation> A findAnnotation(Method method, @Nullable Class<A> annotationType)method when finding repeatable annotations that are declared on custom composed annotations.AnnotationUtils.findAnnotation(someMethod, Roles.class)returnsnullafter upgrading to 5.2.0.RELEASEI've created a sample here to better demonstrate: https://github.com/Walliee/repeatable-annotations
All 3 tests pass on 5.1.10.RELEASE but only 2 on 5.2.0.RELEASE
Affected versions: 5.2.0.RELEASE