Skip to content

Property expansion not properly binded with Configuration properties class #23039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
olayinkasf opened this issue Aug 21, 2020 · 1 comment
Closed
Labels
status: duplicate A duplicate of another issue

Comments

@olayinkasf
Copy link

olayinkasf commented Aug 21, 2020

Duplicating this here from Stackoverflow as I consider it to be an issue/bug.

Property expansion are not properly resolved when the property is binding using ConfigurationProperties. Or more specifically when the property being expanded isn't present, the binding doesn't fail and the property name is used as the value.

Let's look at the following scenario

// The binding class
open class MyProperties {
    lateinit var myValue: String
}

// The configuration
@Configuration
@EnableConfigurationProperties
class MyConfig {
    @Bean
    @ConfigurationProperties(prefix = "my.properties")
    fun myProperties(): MyProperties = MyProperties()
}
## The spring properties yaml
my.properties:
    my-value: ${my.another.value}

When the property my.another.value that is being expanded is present, then the value is present in MyProperties#myValue; however, when the property my.another.value is not present then the raw string "${my.another.value}" is loaded into MyProperties#myValue.

Is there a way to force the application into attempting to expand the property (and failing to startup) instead of using the expansion expression as the value?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 21, 2020
@philwebb
Copy link
Member

Thanks for the report. You're not the first person that has raised this and we actually already have an issue open to add the feature (#18816). We've unfortunately not had the time to provide a solution yet.

@philwebb philwebb added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants