Document @Conditional gating of nested @Configuration classes#36831
Open
Dennis-Mircea wants to merge 1 commit into
Open
Document @Conditional gating of nested @Configuration classes#36831Dennis-Mircea wants to merge 1 commit into
Dennis-Mircea wants to merge 1 commit into
Conversation
Signed-off-by: Dennis-Mircea Ciupitu <dennis.mircea.ciupitu@gmail.com>
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.
Summary
The "With nested
@Configurationclasses" section of the@ConfigurationJavadoc previously mentioned@Profileworking with nested classes but was silent on how@Conditionalinteracts with them. The corresponding reference-doc section ("Conditionally Include@ConfigurationClasses or@BeanMethods" incomposing-configuration-classes.adoc) was similarly silent.In practice, whether an enclosing class's
@Conditionalgates a nested@Configurationdepends on how the nested class is discovered. Nested classes reached through parser recursion from their enclosing class or via@Importinherit the enclosing's conditions through the existingimportedBymechanism (ConfigurationClassBeanDefinitionReader.TrackedConditionEvaluator.shouldSkip). Nested classes discovered independently (via@ComponentScanor by directly registering them) are processed using only their own conditions. The rule is real, long-standing, and currently undocumented.This PR adds a paragraph to the
@ConfigurationJavadoc and a[NOTE]admonition to the reference-doc page documenting that rule and recommending the redeclare-or-meta-annotation workaround when the same gating is intended on independent discovery paths.See also #36820 for a separate proposal to close the discovery-path asymmetry at the framework level. This PR is independent of that proposal; it documents current behavior.
Test plan
./gradlew :spring-context:check(includes javadoc with-Werror, checkstyle, runtime-hints, tests), all green./gradlew :framework-docs:antora, all green@ConfigurationClasses or@BeanMethods"@Configurationverified, new paragraph reads cleanly and{@link}references resolve