gh-9109 and gh-38844 added support for using @NestedConfigurationProperty on a
getter method.
In the configuration processor, the JavaBean path appears to honor that support:
JavaBeanPropertyDescriptor.isMarkedAsNested(...) checks both the field and the getter
The constructor-bound path does not:
ConstructorParameterPropertyDescriptor.isMarkedAsNested(...) checks only the field
As a result, if a constructor-bound @ConfigurationProperties type places
@NestedConfigurationProperty on a getter rather than the field, the processor does
not appear to generate nested group metadata for that property.
I could not tell if this is intentional. The current annotation contract and the
configuration metadata documentation both say that @NestedConfigurationProperty
can be used on a field or a getter method:
@Target includes ElementType.METHOD
- the Javadoc says "The annotation can also be specified on a getter method"
- the configuration metadata reference says the annotation can be used "on a field or a getter method"
For reference, the relevant code paths are:
JavaBeanPropertyDescriptor.isMarkedAsNested(...)
ConstructorParameterPropertyDescriptor.isMarkedAsNested(...)
PropertyDescriptorResolver.resolveConstructorBoundProperties(...)
Should the constructor-bound path align with the JavaBean path here, or is the
current behavior intentional?
gh-9109 and gh-38844 added support for using
@NestedConfigurationPropertyon agetter method.
In the configuration processor, the JavaBean path appears to honor that support:
JavaBeanPropertyDescriptor.isMarkedAsNested(...)checks both the field and the getterThe constructor-bound path does not:
ConstructorParameterPropertyDescriptor.isMarkedAsNested(...)checks only the fieldAs a result, if a constructor-bound
@ConfigurationPropertiestype places@NestedConfigurationPropertyon a getter rather than the field, the processor doesnot appear to generate nested group metadata for that property.
I could not tell if this is intentional. The current annotation contract and the
configuration metadata documentation both say that
@NestedConfigurationPropertycan be used on a field or a getter method:
@TargetincludesElementType.METHODFor reference, the relevant code paths are:
JavaBeanPropertyDescriptor.isMarkedAsNested(...)ConstructorParameterPropertyDescriptor.isMarkedAsNested(...)PropertyDescriptorResolver.resolveConstructorBoundProperties(...)Should the constructor-bound path align with the JavaBean path here, or is the
current behavior intentional?