Skip to content
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

Constructor binding fails when configuration class has a generic field with type parameter java.util.Map #19156

Closed
noriyuki106 opened this issue Nov 27, 2019 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@noriyuki106
Copy link

noriyuki106 commented Nov 27, 2019

Spring Boot: 2.2.1.RELEASE
Operating System: Mac OS 10.14.6 (Mojave)
Kotlin 1.3.60

In my application, I have a configuration class with generic field, but this does not work with @ConstructorBinding when type parameter is java.util.Map:

@ConfigurationProperties(prefix = "demo.prop")
@ConstructorBinding
data class ConstructorBindingPropWithGeneric(@NestedConfigurationProperty var field: GenericObj<Map<String, String>>) {

    data class GenericObj<T>(
        val subField: T
    )

}

I was using following declaration before @ConstructorBinding, and it was working:

@ConfigurationProperties(prefix = "demo.prop")
class OldStylePropWithGeneric {

    @NestedConfigurationProperty
    var field: GenericObj<Map<String, String>>? = null

    class GenericObj<T> {
        var subField: T? = null
    }

}

I think @ConstructorBinding should work in this case too.

Example project: demo1.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2019
@philwebb philwebb changed the title constructor binding fails when configuration class has a generic field with type parameter java.util.Map Constructor binding fails when configuration class has a generic field with type parameter java.util.Map Dec 2, 2019
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 2, 2019
@philwebb philwebb added this to the 2.2.x milestone Dec 2, 2019
@mbhave mbhave self-assigned this Dec 3, 2019
@mbhave mbhave closed this as completed in f4db8c8 Dec 3, 2019
@mbhave mbhave modified the milestones: 2.2.x, 2.2.2 Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants