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

Activity

Brett MeyerOctober 31, 2013 at 12:21 PM

Good catch, thanks

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created March 11, 2011 at 9:28 AM
Updated April 22, 2015 at 6:40 PM
Resolved October 31, 2013 at 12:42 PM