Skip to content

Regression: attribute override configured via @AliasFor no longer honored in annotation hierarchy #23767

@flozano

Description

@flozano

Reproduced in
flozano/spring-framework-issues@bbc160d

We use meta-annotations for using different transaction managers in different areas of the app.

During the upgrade to 5.2.0.RELEASE, we found that the wrong transaction manager was being used in many cases.

I haven't investigated deep enough, but I have put together a reproducing project that works well in Spring 5.1.9 but fails in 5.2.0.

What I have observed is that the behaviour of AnnotatedElementUtils#findMergedAnnotationAttributes is different than it was for 5.1.9.RELEASE when @AliasFor appears, basically not propagating the value that I set in the meta-annotations to @Transactional.

What I have is:

@Transactional
@Retention(RetentionPolicy.RUNTIME)
public @interface MyTransactional {

	@AliasFor(annotation = Transactional.class, attribute = "value")
	String value() default "defaultTransactionManager";

	@AliasFor(annotation = Transactional.class, attribute = "isolation")
	Isolation isolation() default Isolation.DEFAULT;

}

and

@MyTransactional(value = "anotherTransactionManager")
@Retention(RetentionPolicy.RUNTIME)
public @interface AnotherMyTransactional {

}

and when I try to use @AnotherMyTransactional, findMergedAnnotationAttributes gets an empty value for value field (transaction manager qualifier) , whereas in 5.1.9.RELEASE it obtains the right one.

Metadata

Metadata

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions