Skip to content
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

Correctly parse property name in path "map[key[foo]]" #21855

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

mkurz
Copy link
Contributor

@mkurz mkurz commented Jan 11, 2019

We have a Bean that contains a Map. In this Map we want to save properties with property names which contain an index that is relevant for our application only, like key5[foo]. For spring that index doesn't matter, it should just treat key5[foo] as property name.
However spring-bean is not able to correctly retrieve the property name, it tries to retrieve key5[foo (missing square bracket at the end). That's because spring just looks for the first occurrence of ] and thinks it's the closing square bracket of the property name, however in our case that square bracket is part of the property name, and the relevant square bracket for spring (to actually close the property name) comes afterwards.

  • Added tests
  • Signed the CLA.

Would be nice if this could be backported to 5.1.x.
Thanks!

@mkurz
Copy link
Contributor Author

mkurz commented Jan 11, 2019

The Codacy check fails because the switch statement I added does not have a default. However that isn't necessary for the logic I added.
Do I really have to add an empty/no-op default to that switch statement?

@mkurz
Copy link
Contributor Author

mkurz commented Jan 21, 2019

@jhoeller any chance you will assign this issue to the 5.1.5 milestone? I think the bug here - as well as the fix - is obvious. Thanks!

@jhoeller jhoeller self-assigned this Jan 21, 2019
@jhoeller jhoeller added this to the 5.1.5 milestone Jan 21, 2019
@jhoeller jhoeller added the type: enhancement A general enhancement label Jan 22, 2019
@jhoeller jhoeller modified the milestones: 5.1.5, 5.2 M2 Jan 30, 2019
@jhoeller
Copy link
Contributor

On review, I'll rather make this a 5.2 topic since the bean property binding is a high-risk area for regressions. Even if some such paths are not meant to be valid from our side, people may encounter e.g. property paths with incomplete nested brackets which we would possibly parse differently then.

@jhoeller jhoeller added the in: core Issues in core modules (aop, beans, core, context, expression) label Mar 27, 2019
@jhoeller jhoeller modified the milestones: 5.2 M2, 5.2 M1 Mar 31, 2019
@jhoeller jhoeller merged commit 6899624 into spring-projects:master Apr 2, 2019
@mkurz mkurz deleted the fix-property-key-end branch April 2, 2019 13:16
jhoeller added a commit that referenced this pull request Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants