Skip to content

UnboundConfigurationPropertiesException is no longer thrown from IndexedElementsBinder #45994

Closed
@winfriedgerlach

Description

@winfriedgerlach

Short story:

IndexedElementsBinder from Spring 3.5.0 doesn't throw UnboundConfigurationPropertiesException on missing target field any more, even on first element in a list.

Long story:

We are using Spring Boot to bind a list of configuration properties from a file to a @ConfigurationProperties class.

Our configuration looks like this:

prefix.list[0].a=value1
prefix.list[0].b=value2
prefix.list[1].a=value3
prefix.list[1].b=value4

(in fact, we are mapping lists of lists, but I think that our problem would also occur for a simple list)

With prior Spring Boot versions, both prefix.list[5].a=someValue and prefix.list[0].foo=someValue would throw UnboundConfigurationPropertiesException:

  • the former due to a "binding gap" in the list
  • the latter because the field "foo" does not exist in the target object (cf. IndexedElementsBinder 3.4.x: if (value == null) { break; }). This validation is now broken in Spring Boot 3.5.0.

Deeper analysis showed that our problem is caused by the changes in #44867. We are not particularly happy about these changes, because

  1. for us, full validation is more important than performance (sure, other users have other needs, cf. Provide a possibility to extend/override configuration properties binding process #42361) and
  2. @philwebb's assessment "with YAML configuration lists are unlikely to have missing elements" does not apply to us, as we are using plain old properties files

But even if we accept that configuration validation is only performed on the first 10 items in the list, IMHO Spring Boot should still detect if the target field does not exist. This was probably just an oversight when implementing #93113a4 ?

We would be glad if you had a look into this issue. Thanks everyone!

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions