We're updating the issue view to help you get more done. 

StructuredCacheEntry shall pass correct expected map size and loadFactor for HashMap constructor

Description

There is a code in StructuredCacheEntry::structure that supposed to optimize usage of HashMap and not allow resizing of HashMap. But it doesn't work. To check put a breakpoint at hashmap::resize and call for StructuredCacheEntry::structure method:

at java.util.HashMap.resize(HashMap.java:462)
at java.util.HashMap.addEntry(HashMap.java:755)
at java.util.HashMap.put(HashMap.java:385)
at org.hibernate.cache.entry.StructuredCacheEntry.structure(StructuredCacheEntry.java:67)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:195)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)

I believe the line

Map map = new HashMap(names.length+2);

shall be rewritten as

Map map = new HashMap(names.length+3, 1.0);

Environment

None

Status

Assignee

Brett Meyer

Reporter

Sergey Vladimirov

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

3.6.0

Priority

Major