diff --git a/src/main/java/org/apache/ibatis/executor/resultset/PendingConstructorCreation.java b/src/main/java/org/apache/ibatis/executor/resultset/PendingConstructorCreation.java index 03cbc21397e..14703a04960 100644 --- a/src/main/java/org/apache/ibatis/executor/resultset/PendingConstructorCreation.java +++ b/src/main/java/org/apache/ibatis/executor/resultset/PendingConstructorCreation.java @@ -44,9 +44,11 @@ final class PendingConstructorCreation { private final Map> linkedCreationsByResultMapId; PendingConstructorCreation(Class resultType, List> types, List args) { - this.linkedCollectionMetaInfo = new HashMap<>(); - this.linkedCollectionsByResultMapId = new HashMap<>(); - this.linkedCreationsByResultMapId = new HashMap<>(); + // since all our keys are based on result map id, we know we will never go over args size + final int maxSize = types.size(); + this.linkedCollectionMetaInfo = new HashMap<>(maxSize); + this.linkedCollectionsByResultMapId = new HashMap<>(maxSize); + this.linkedCreationsByResultMapId = new HashMap<>(maxSize); this.resultType = resultType; this.constructorArgTypes = types; this.constructorArgs = args; @@ -67,7 +69,7 @@ Collection initializeCollectionForResultMapping(ObjectFactory objectFact linkedCollectionMetaInfo.put(index, new PendingCreationMetaInfo(resultMap.getType(), resultMapId)); // will be checked before we finally create the object) as we cannot reliably do that here - return (Collection) objectFactory.create(constructorMapping.getJavaType()); + return (Collection) objectFactory.create(parameterType); }); }