apache / apache/rocketmq-spring
fix: AnnotationEnhancer chain silently discards all modifications in RocketMQMessageListenerBeanPostProcessor
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 943
- PR merge metrics
- No merged PRs in 30d
Description
## Bug Description
In `RocketMQMessageListenerBeanPostProcessor.buildEnhancer()`, the composed `AnnotationEnhancer` lambda correctly accumulates modified attributes through all registered enhancer beans into `newAttrs`, but then **returns the original `attrs`** instead of `newAttrs`.
This makes every registered `AnnotationEnhancer` bean a **silent no-op** — attribute modifications are computed but immediately discarded.
## Affected Version
`2.3.6` (rocketmq-v5-client-spring-boot)
## Root Cause
`RocketMQMessageListenerBeanPostProcessor.buildEnhancer()`:
```java
this.enhancer = (attrs, element) -> {
Map newAttrs = attrs;
for (AnnotationEnhancer enh : enhancers) {
newAttrs = enh.apply(newAttrs, element); // accumulates correctly
}
return attrs; // BUG: discards all changes, should be newAttrs
};
```
## Expected Behavior
`AnnotationEnhancer` beans registered in the Spring context should be able to override `@RocketMQMessageListener` annotation attributes (e.g. topic, consumerGroup) at runtime.
## Actual Behavior
All `AnnotationEnhancer` customizations are silently ignored. The original annotation attributes are always used.
## Impact
Any application that relies on `AnnotationEnhancer` to dynamically override `@RocketMQMessageListener` attributes — for example, injecting topic or consumerGroup from environment properties — will find their customizations have no effect.
## Fix
Return `newAttrs` instead of `attrs`:
```java
return newAttrs;
```
A pull request with the fix has been submitted: https://github.com/apache/rocketmq-spring/pull/775
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.