Repository navigation
Resolve property placeholders in constructor binding default values - #51661
Merged
wilkinsona merged 2 commits intoSep 11, 2026
Merged
wilkinsona merged 2 commits into
wilkinsona merged 2 commits into
Conversation
wilkinsona
requested changes
Sep 11, 2026
| @Nullable Object[] resolved = new Object[defaultValue.length]; | ||
| boolean strings = true; | ||
| for (int i = 0; i < defaultValue.length; i++) { | ||
| Object value = resolver.resolvePlaceholders(defaultValue[i]); |
Member
There was a problem hiding this comment.
For simplicity and consistency with PropertySourcesPlaceholdersResolver, I think String.valueOf(value) should be used here. That will remove the need for the strings boolean and allow a String[] to be returned.
Contributor
Author
There was a problem hiding this comment.
Thanks, Andy. Updated in bc60f1f to use String.valueOf(value), remove the strings flag and conditional array handling, and return String[]. The configuration-properties and conversion tests passed locally (1,220 tests, 0 failures/errors, 1 skipped), along with formatting and Checkstyle checks.
Wanbinyu
added a commit
to Wanbinyu/spring-boot
that referenced
this pull request
Sep 11, 2026
Use String.valueOf for consistency with PropertySourcesPlaceholdersResolver and remove the conditional array type handling. See spring-projectsgh-51661 Signed-off-by: Wan bin yu <[email protected]>
Resolve each annotated default using the binder placeholder resolver before conversion. Signed-off-by: Wan bin yu <[email protected]> See spring-projectsgh-51661
…values" See spring-projectsgh-51661 Signed-off-by: Andy Wilkinson <[email protected]>
wilkinsona
force-pushed
the
gh-29495-default-value-placeholders
branch
from
September 11, 2026 16:30
bc60f1f to
b5dd521
Compare
Member
|
Thank you, @Wanbinyu. |
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.
Resolve property placeholders in
@DefaultValuebefore converting constructor arguments, following the team decision in #29495 (comment).For example, with
defaults.duration=3d, a constructor parameter annotated with@DefaultValue("${defaults.duration:1d}")now receivesDuration.ofDays(3)when no explicit value is configured for that parameter. Withoutdefaults.duration, it receivesDuration.ofDays(1).The change uses the Binder's existing
PlaceholdersResolverfor each default value andString.valueOfto return the resolved values as aString[], consistently withPropertySourcesPlaceholdersResolver. Explicit property values still take precedence; empty@DefaultValuehandling and ordinary field initializers are unchanged. Update the annotation's Javadoc accordingly.Verification (Java 25):
@EnableConfigurationProperties, checking the constructed bean's string, Duration, primitive-array and collection values. The initial reproduction failed before the production change (2 failing default-value cases, with the explicit-override control passing).*context.properties.*and*boot.convert.*: 1,220 tests, 0 failures/errors, 1 skipped.:core:spring-boot:checkstyleMain,checkstyleTest,checkFormatMain, andcheckFormatTestpassed.This targets
main, not a maintenance branch: resolving placeholders in defaults is an intentional behavior change for applications that previously received the literal placeholder. This does not change default-value collection conversion rules or resolve placeholders in ordinary field initializers. The entire repository test suite was not run.Closes #29495.