Skip to content

Commit 2ee5bf1

Browse files
authored
Merge pull request #907 from hexetia/fix-901
Fix a bug when calling JSONArray.addAll() with Collection as Object
2 parents e7e52da + 14e9cdc commit 2ee5bf1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/org/json/JSONArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ private void addAll(Object array, boolean wrap, int recursionDepth, JSONParserCo
19391939
// JSONArray
19401940
this.myArrayList.addAll(((JSONArray)array).myArrayList);
19411941
} else if (array instanceof Collection) {
1942-
this.addAll((Collection<?>)array, wrap, recursionDepth);
1942+
this.addAll((Collection<?>)array, wrap, recursionDepth, jsonParserConfiguration);
19431943
} else if (array instanceof Iterable) {
19441944
this.addAll((Iterable<?>)array, wrap);
19451945
} else {

src/test/java/org/json/junit/JSONArrayTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ public void verifyPutAll() {
259259
jsonArray.length(),
260260
len);
261261

262+
// collection as object
263+
@SuppressWarnings("RedundantCast")
264+
Object myListAsObject = (Object) myList;
265+
jsonArray.putAll(myListAsObject);
266+
262267
for (int i = 0; i < myList.size(); i++) {
263268
assertEquals("collection elements should be equal",
264269
myList.get(i),

0 commit comments

Comments
 (0)