Skip to content

[ISSUE #501] fix(spring): remove ineffective @AutoConfigureAfter/Before on imported configurations - #784

Open
NUAAwqy wants to merge 1 commit into
apache:masterfrom
NUAAwqy:fix/autoconfigure-ordering-usage-501
Open

NUAAwqy wants to merge 1 commit into
apache:masterfrom
NUAAwqy:fix/autoconfigure-ordering-usage-501

Conversation

@NUAAwqy

@NUAAwqy NUAAwqy commented Nov 11, 2026

Copy link
Copy Markdown

What is the purpose of the change

Fix #501.

@AutoConfigureAfter / @AutoConfigureBefore only take effect between auto-configuration classes that are registered in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports (or, historically, spring.factories). In both modules of this project the imports file registers exactly one class, RocketMQAutoConfiguration; MessageConverterConfiguration, RocketMQTransactionConfiguration and RocketMQListenerConfiguration are all pulled in through @Import on that entry class.

The annotations below therefore never influenced any ordering:

  • RocketMQAutoConfiguration: @AutoConfigureAfter({MessageConverterConfiguration.class}) and @AutoConfigureBefore({RocketMQTransactionConfiguration.class})
  • RocketMQListenerConfiguration (both modules): @AutoConfigureAfter(RocketMQAutoConfiguration.class)

They mislead readers into copying the pattern (as noted in the issue), so this PR removes them. The removal is behavior-preserving: an ordering annotation whose target is not a registered auto-configuration has no effect, and @Import already determines the processing of the imported configurations.

Brief changelog

  • Remove ineffective @AutoConfigureAfter / @AutoConfigureBefore declarations from the four configuration classes
  • Add AutoConfigurationOrderingUsageTest to both modules: asserts that no ordering annotation is declared on the imported configurations, and that any declared ordering target must be a class registered in AutoConfiguration.imports

Verifying this change

  • mvn -pl rocketmq-spring-boot,rocketmq-v5-client-spring-boot -am test on JDK 17: BUILD SUCCESS
  • rocketmq-spring-boot: 43 tests, 0 failures (including the existing RocketMQAutoConfigurationTest, confirming bean wiring is unchanged)
  • rocketmq-v5-client-spring-boot: 2 tests, 0 failures

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title following [ISSUE #xxx] Summary of the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write necessary unit-test to verify your logic correction, add more mock test, necessary javadoc for doc changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

…r/Before on imported configurations

@AutoConfigureAfter and @AutoConfigureBefore only order auto-configuration
classes that are registered in META-INF/spring/...AutoConfiguration.imports.
In both rocketmq-spring-boot and rocketmq-v5-client-spring-boot the only
registered entry class is RocketMQAutoConfiguration; MessageConverterConfiguration,
RocketMQTransactionConfiguration and RocketMQListenerConfiguration are pulled in
via @import, so the ordering annotations on them never take effect.

Removed the dead annotations (behavior-preserving) and added a regression
test per module asserting that no ordering annotation is declared on the
imported configurations and that any ordering target would have to be a
registered auto-configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant