Skip to content

Consider not overriding meta-annotation attributes if empty [SPR-11709] #16331

Closed
@spring-projects-issues

Description

@spring-projects-issues

Gary Russell opened SPR-11709 and commented

In AnnotationReadingVisitorUtils.getMergedAnnotationAttributes(), the attributes closer to the annotated element override those in the hierarchy.

It would be useful if this only occurred if the closer attribute was not-empty.

For example:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@MessagingGateway(defaultRequestChannel = "gatewayChannel",
		defaultHeaders = @GatewayHeader(name = "foo", value = "FOO"))
public static @interface TestMessagingGateway {

	String defaultRequestChannel() default "";
}

This allows the user to override the "default" setting in the meta-annotation, but the current logic replaces the default with "" if the user does not specify a value when using the annotation.

The same applies to attributes with array values; consider preventing the override of a higher-up array with an empty array closer to the declaration.


Affects: 4.0.3

Issue Links:

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions