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

spring-issuemaster opened this issue Feb 25, 2016 · 2 comments


Copy link

@spring-issuemaster spring-issuemaster 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:

  • #19593 LinkedCaseInsensitiveMap does not properly support Java 8's merge() and compute() methods
  • #19078 LinkedCaseInsensitiveMap doesn't override HashMap.clone()
  • #21126 Inconsistent handling of null values through Java 8 accessors in ConcurrentReferenceHashMap
  • #21465 LinkedCaseInsensitiveMap should explicitly implement putIfAbsent and computeIfAbsent

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 25, 2016

Martin Macko commented

I've submitted a PR, that fixes this.


This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 25, 2016

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.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.