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)
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);