Closed
Description
Gary Russell opened SPR-11710 and commented
List<AnnotationAttributes> attributesList = attributesMap.get(annotationType);
...
AnnotationAttributes results = attributesList.get(0);
...
results.put(overridableAttributeName, value);
gets a hard reference to the map element and removes the value from that entry's list.
Consider:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@MessagingGateway(defaultRequestChannel = "gatewayChannel", defaultReplyChannel = "gatewayChannel",
defaultHeaders = @GatewayHeader(name = "foo", value = "FOO"))
public static @interface TestMessagingGateway {
String defaultRequestChannel() default "";
}
and
MultiValueMap<String, Object> metaAttributesMap = importingClassMetadata.getAllAnnotationAttributes(MessagingGateway.class.getName());
Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(MessagingGateway.class.getName());
metaAttributesMap = importingClassMetadata.getAllAnnotationAttributes(MessagingGateway.class.getName());
first call to getAllAnnotationAttributes()
:
{asyncExecutor=[], mapper=[], errorChannel=[], defaultRequestChannel=[gatewayChannel], ...
second call:
{name=[], asyncExecutor=[], mapper=[], errorChannel=[], defaultRequestChannel=[], ...
Affects: 4.0.3
Issue Links:
- Support meta-annotation attribute overrides in ASM-based annotation processing [SPR-11574] #16198 Support meta-annotation attribute overrides in ASM-based annotation processing
- AnnotationReadingVisitorUtils.getMergedAnnotationAttributes() overrides values it should not [SPR-11649] #16272 AnnotationReadingVisitorUtils.getMergedAnnotationAttributes() overrides values it should not