-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Inconsistency between binder property paths #17615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@copitz I'm not sure I fully understood the issue. A minimal sample that showcases the issue or a test case would be very useful. |
@mbhave Sure, hope this helps: https://github.com/copitz/spring-boot-issue-17615 |
Thanks for the sample @copitz. I took a look and this is the expected behavior: When
This is why it works when you add the When you use Spring Boot's One way to avoid manually fixing the property names would be to specify the properties using the convention mentioned in the docs linked above. Using We have an open issue #13404 for investigating if map keys can preserve their original value without having to surround them with |
Thank you @mbhave for the clarification |
Uh oh!
There was an error while loading. Please reload this page.
TL;DR:
The keys of nested properties bound to a
Map<String, String>
look like"foo.0.bar"
but should be"foo[0].bar"
.Further explanation:
This one took me hours to figure out and I managed to work around it by replacing all
"\\.([0-9]+)(\\.|$)"
with[$1]$2
in the keys of the map - anyway I think that it could help someone stumbling upon this and especially when it could be fixed:To enable polymorph configuration property bindings (and also retrieve such bindings from other sources like a database or webservice) I let spring boot bind (nested) properties under a certain path to a
Map<String, String>
and use this asMapConfigurationPropertySource
for the new Binder API to bind them to the concrete classes.This worked fine until I stumbled upon collections/arrays leading to weired behaviors of the binder (e.g. keeping dots in the property path). After a while I found out that this was caused by the wrong form of the property paths.
Please let me know if I should add some code / test case to make this clearer.
The text was updated successfully, but these errors were encountered: