Skip to content

fix: AnnotationEnhancer chain silently discards all modifications in RocketMQMessageListenerBeanPostProcessor #776

@lossend

Description

@lossend

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():

this.enhancer = (attrs, element) -> {
    Map<String, Object> 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:

return newAttrs;

A pull request with the fix has been submitted: #775

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions