Skip to content

fix: AnnotationEnhancer chain silently discards all modifications#775

Open
lossend wants to merge 1 commit into
apache:masterfrom
lossend:fix/annotation-enhancer-return-newAttrs
Open

fix: AnnotationEnhancer chain silently discards all modifications#775
lossend wants to merge 1 commit into
apache:masterfrom
lossend:fix/annotation-enhancer-return-newAttrs

Conversation

@lossend

@lossend lossend commented Jun 15, 2026

Copy link
Copy Markdown

Fixes #776

Problem

In RocketMQMessageListenerBeanPostProcessor.buildEnhancer(), the lambda accumulates
enhanced annotation attributes into newAttrs across all registered AnnotationEnhancer
beans, but then returns the original attrs instead of newAttrs.

This means every AnnotationEnhancer bean is silently a no-op — its attribute
modifications are computed but thrown away.

Fix

Return newAttrs instead of attrs.

// before
return attrs;

// after
return newAttrs;

Root Cause

buildEnhancer() (line 178–184):

this.enhancer = (attrs, element) -> {
    Map<String, Object> newAttrs = attrs;
    for (AnnotationEnhancer enh : enhancers) {
        newAttrs = enh.apply(newAttrs, element);
    }
    return attrs;   // BUG: should be newAttrs
};

Impact

Any application that relies on AnnotationEnhancer to dynamically override @RocketMQMessageListener attributes (e.g. injecting topic/group from environment properties) will find their customizations have no effect.

…chain

The buildEnhancer lambda was accumulating enhanced attributes into newAttrs
across all AnnotationEnhancer beans, but then returned the original attrs —
making all enhancers silently no-op.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: AnnotationEnhancer chain silently discards all modifications in RocketMQMessageListenerBeanPostProcessor

1 participant