Skip to content

Commit 98075c3

Browse files
philwebbcbeams
authored andcommitted
Chain exception cause on create failure
Propogate root cause of exceptions thrown from createCollection and createMap. Issue: SPR-9285 Backport-Commit: 2e48656
1 parent 4cee691 commit 98075c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ else if (Set.class.equals(collectionType) || Collection.class.equals(collectionT
255255
return (Collection) collectionType.newInstance();
256256
}
257257
catch (Exception ex) {
258-
throw new IllegalArgumentException("Could not instantiate Collection type: " + collectionType.getName());
258+
throw new IllegalArgumentException("Could not instantiate Collection type: " +
259+
collectionType.getName(), ex);
259260
}
260261
}
261262
}
@@ -322,7 +323,8 @@ else if (MultiValueMap.class.equals(mapType)) {
322323
return (Map) mapType.newInstance();
323324
}
324325
catch (Exception ex) {
325-
throw new IllegalArgumentException("Could not instantiate Map type: " + mapType.getName());
326+
throw new IllegalArgumentException("Could not instantiate Map type: " +
327+
mapType.getName(), ex);
326328
}
327329
}
328330
}

0 commit comments

Comments
 (0)