Configure @ConfigurationProperties binding for programmatically regis…#50488
Closed
ujjawal-tyagi wants to merge 1 commit into
Closed
Configure @ConfigurationProperties binding for programmatically regis…#50488ujjawal-tyagi wants to merge 1 commit into
ujjawal-tyagi wants to merge 1 commit into
Conversation
…tered beans When beans annotated with @ConfigurationProperties are registered programmatically (for example, via BeanRegistrar or registerBeanDefinition) without going through ConfigurationPropertiesBeanRegistrar, the required BindMethodAttribute is not stamped on the BeanDefinition. This causes ConfigurationPropertiesBindingPostProcessor to fall back to setter-based binding, which fails for immutable types such as Kotlin data classes. Introduce ConfigurationPropertiesBeanDefinitionPostProcessor, a BeanDefinitionRegistryPostProcessor with HIGHEST_PRECEDENCE that runs before bean instantiation. It iterates all registered bean definitions and, for any @ConfigurationProperties type that lacks BindMethodAttribute, delegates to the new ConfigurationPropertiesBeanRegistrar.enrichBeanDefinition static method. This keeps the enrichment logic in a single place: the same deduceBindMethod call and instanceSupplier setup used by the existing scan and @enable paths. Closes gh-xxxx Signed-off-by: ujjawal tyagi <ujjawaltyagi@gmail.com>
2d20816 to
3d56d76
Compare
Member
|
Thanks for trying to help but working on an issue that is waiting-for-triage is not a good idea. The issue has been triaged and rejected, see the conversation in #50486 |
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.
…tered beans
When beans annotated with @ConfigurationProperties are registered programmatically (for example, via BeanRegistrar or registerBeanDefinition) without going through ConfigurationPropertiesBeanRegistrar, the required BindMethodAttribute is not stamped on the BeanDefinition. This causes ConfigurationPropertiesBindingPostProcessor to fall back to setter-based binding, which fails for immutable types such as Kotlin data classes.
Introduce ConfigurationPropertiesBeanDefinitionPostProcessor, a BeanDefinitionRegistryPostProcessor with HIGHEST_PRECEDENCE that runs before bean instantiation. It iterates all registered bean definitions, deduces the correct BindMethod for any @ConfigurationProperties type that lacks the attribute, and stamps BindMethodAttribute accordingly. For VALUE_OBJECT types it also installs a constructor-binding instanceSupplier via ConstructorBound. Additionally, it deduplicates scan-registered definitions when a custom registration exists for the same type.
Closes gh-xxxx