Skip to content

ConfigurationPropertiesBean detects class-level @ConstructorBinding unexpectedly #18685

Closed
@snicoll

Description

@snicoll

Consider the following:

@ConfigurationProperties("test")
@ConstructorBinding
public class TestProperties {

    public TestProperties(String property, int counter) { ... }

}

And the current code:

Constructor<?> bindConstructor = BindMethod.findBindConstructor(type);
BindMethod bindMethod = (bindConstructor != null) ? BindMethod.VALUE_OBJECT : BindMethod.forClass(type);

BindMethod.findBindConstructor(TestProperties.class) will return null as it does not test the fact @ConstructorBinding is specified at class level. However, BindMethod.forClass(type) will work as it has the extra assertion.

The current code arrangement feels a bit weird considering we have a dedicated method to retrieve the relevant constructor and that returns null whereas it shouldn't.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions