Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions