-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Description
Given
@ConfigurationProperties("foo.bar")
public class GenericProperties extends AbstractPropeties<Foo> {
}
and
public class AbstractPropeties<T> {
private Map<String, T> props;
public Map<String, T> getProps() {
return props;
}
public void setProps(Map<String, T> props) {
this.props = props;
}
}
The generated metadata is
{
"groups": [
{
"name": "foo.bar",
"type": "com.example.GenericProperties",
"sourceType": "com.example.GenericProperties"
}
],
"properties": [
{
"name": "foo.bar.props",
"type": "java.util.Map<java.lang.String,T>",
"sourceType": "com.example.GenericProperties"
}
],
"hints": []
}
Should be
{
"groups": [
{
"name": "foo.bar",
"type": "com.example.GenericProperties",
"sourceType": "com.example.GenericProperties"
}
],
"properties": [
{
"name": "foo.bar.props",
"type": "java.util.Map<java.lang.String,com.example.Foo>",
"sourceType": "com.example.GenericProperties"
}
],
"hints": []
}
The generator should be able to determine the generic type.
Per Kris De Volder in Slack
Generics is complex, so I'm never surprised if it breaks stuff like this. But in my opinion it should be considered a bug. The method may be inherted from a generic superclass (or overridden). But from the subclass point of view we know that type 'T' is really 'RabbitBindingProperties'. So its reasonable to expect the Spring boot annotation processor to treat 'T' as if it is equal to 'RabbitBindingProperties' in that context.
So I think you should raise a bug against spring boot configuration processor.
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug