Skip to content

Metadata annotation processor ignores method-level @NestedConfigurationProperty when using constructor binding #49734

@dlwldnjs1009

Description

@dlwldnjs1009

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?

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions