Despite stricter property binding in spring-boot 3.5.0 everything worked.
From spring-boot 3.5.1 (including 3.5.3) properties from nested collections cannot be bound from environment variables anymore.
Working example with spring-boot 3.5.0: https://github.com/sandra-markerud/spring-demos/blob/main/src/test/kotlin/de/markerud/PropertiesTest.kt https://github.com/sandra-markerud/spring-demos/blob/main/src/test/kotlin/de/markerud/EnvSyntaxTest.kt
Broken example with spring-boot 3.5.3: https://github.com/sandra-markerud/spring-demos/blob/feature/env-injection-failure/src/test/kotlin/de/markerud/PropertiesTest.kt https://github.com/sandra-markerud/spring-demos/blob/feature/env-injection-failure/src/test/kotlin/de/markerud/EnvSyntaxTest.kt
Comment From: TimothyEarley
Ran into the same issue.
For me the fix was renaming the env variables to closer match what is written in the docs. The relevant part is that -
is to be removed, not substituted by _
. E.g. SOME_PROPS_NESTED_PROPS_NESTED_COLLECTION_0_SOME_ID
should actually be SOME_PROPS_NESTEDPROPS_NESTEDCOLLECTION_0_SOMEID
.
With that change your example works (thanks for providing it btw 👍).
Now, I am not sure what change caused this, so if someone from the Spring Team could clarify this it would be greatly appreciated. I assume quite a few projects will be impacted.
Comment From: philwebb
This looks quite similar to #45741
Comment From: philwebb
@sandra-markerud Thanks for the sample. For me EnvSyntaxTest
is failing but PropertiesTest
is working with 3.5.3. What failures are you seeing with that test?
Comment From: philwebb
I've tracked down what's going on. In IndexedElementsBinder
we are now filtering the source here which is limiting the number of that can be bound. Unfortunately, this is not picking up the legacy support in SystemEnvironmentPropertyMapper
.
I think this explains why SOME_PROPS_NESTEDPROPS_NESTEDCOLLECTION_0_SOMEID
works but SOME_PROPS_NESTED_PROPS_NESTED_COLLECTION_0_SOME_ID
doesn't.
I'm going to back out that optimization in 3.5 and we'll perhaps have another go at implementing it in 4.0.
Comment From: sandra-markerud
@sandra-markerud Thanks for the sample. For me
EnvSyntaxTest
is failing butPropertiesTest
is working with 3.5.3. What failures are you seeing with that test?
Sorry, my initial comment was a bit misleading. I am not seeing any problems with the 'PropertiesTest' but only with the 'EnvSyntaxTest'.
For us it is quite important to restore the initial behaviour. Otherwise we would need to introduce breaking changes in our Kubernetes environments.