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

LinkedCaseInsensitiveMap doesn't implement getOrDefault properly [SPR-13981] #18553

Closed
spring-projects-issues opened this issue Feb 25, 2016 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 25, 2016

Alexey Pomelov opened SPR-13981 and commented

The default getOrDefault method implemented in the java.util.Map interface uses only get and containsKey methods. Within the LinkedCaseInsensitiveMap class these methods work with special form of keys. But getOrDefault method is overriden also in HashMap and LinkedHashMap and it calculates hashes for keys itself.

As a result can get this behavior.
Assuming select a single row via jdbc template with the column IS_SINGLE=Y
Here are results of some method calls to the resulting map:

map.containsKey("is_single") // true
map.containsKey("IS_SINGLE") // true
map.get("is_single") // Y
map.get("IS_SINGLE") // Y
map.getOrDefault("is_single", "N") // N !!!
map.getOrDefault("IS_SINGLE", "N") // Y

Affects: 4.2.4

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Martin Macko commented

I've submitted a PR, that fixes this.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Thanks for the report and the pull request, guys! Fixed as part of a slightly wider revision of that class, also handling stored null values correctly.

Juergen

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: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants