Do not recursively try to reset configuration properties for library types#1699
Merged
Conversation
…types Also add a configuration property that can be set to add additional classes that should be skipped as well. Fixes #1698
spencergibb
approved these changes
Jun 17, 2026
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.
Fixes #1698
PR #1680 (released in 5.0.2) added logic to ConfigurationPropertiesRebinder that resets a
@ConfigurationPropertiesbean's fields to their class-level defaults during a rebind, so that properties removed from the Environment don't retain stale values. For nested, non-simple property values it recurses:This recursion had no cycle detection and no restriction on which types it descended into. When a
@ConfigurationPropertiesbean exposes a field of a JDK or library type the reset walks that type's internal object graph.SSLContext's graph is cyclic, so the recursion never terminates and throwsStackOverflowErrorduring rebind.The recursion is now bounded and restricted to types it makes sense to reset (user-defined nested configuration properties), with a configurable escape hatch:
Collections.newSetFromMap(new IdentityHashMap<>())). Revisiting an instance short-circuits, guaranteeing the recursion always terminatesjakarta.*and legacyjavax.*API types are loaded by the application class loader, the class-loader check above does not catch them.spring.cloud.refresh.never-reset-nested-typesaccepts a comma-separated list of fully qualified class names or package prefixes to additionally skip