Repository navigation
[ISSUE #501] fix(spring): remove ineffective @AutoConfigureAfter/Before on imported configurations - #784
Open
NUAAwqy wants to merge 1 commit into
Open
[ISSUE #501] fix(spring): remove ineffective @AutoConfigureAfter/Before on imported configurations#784NUAAwqy wants to merge 1 commit into
NUAAwqy wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fix #501.
@AutoConfigureAfter/@AutoConfigureBeforeonly take effect between auto-configuration classes that are registered inMETA-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,RocketMQTransactionConfigurationandRocketMQListenerConfigurationare all pulled in through@Importon 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
@Importalready determines the processing of the imported configurations.Brief changelog
@AutoConfigureAfter/@AutoConfigureBeforedeclarations from the four configuration classesAutoConfigurationOrderingUsageTestto both modules: asserts that no ordering annotation is declared on the imported configurations, and that any declared ordering target must be a class registered inAutoConfiguration.importsVerifying this change
mvn -pl rocketmq-spring-boot,rocketmq-v5-client-spring-boot -am teston JDK 17: BUILD SUCCESSRocketMQAutoConfigurationTest, confirming bean wiring is unchanged)Follow this checklist to help us incorporate your contribution quickly and easily:
[ISSUE #xxx] Summary of the change.