From 87bf1f3d2ed6863a63c2cf418068cfbc02647100 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:26:32 +0100 Subject: [PATCH] fixed files form Lang #37 --- projects/Lang/37/org/apache/commons/lang3/ArrayUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/Lang/37/org/apache/commons/lang3/ArrayUtils.java b/projects/Lang/37/org/apache/commons/lang3/ArrayUtils.java index 889497e..b9413e8 100644 --- a/projects/Lang/37/org/apache/commons/lang3/ArrayUtils.java +++ b/projects/Lang/37/org/apache/commons/lang3/ArrayUtils.java @@ -2959,8 +2959,16 @@ public static T[] addAll(T[] array1, T... array2) { final Class type1 = array1.getClass().getComponentType(); T[] joinedArray = (T[]) Array.newInstance(type1, array1.length + array2.length); System.arraycopy(array1, 0, joinedArray, 0, array1.length); + try { System.arraycopy(array2, 0, joinedArray, array1.length, array2.length); + } catch (ArrayStoreException ase) { // Check if problem is incompatible types + final Class type2 = array2.getClass().getComponentType(); + if (!type1.isAssignableFrom(type2)){ + throw new IllegalArgumentException("Cannot store "+type2.getName()+" in an array of "+type1.getName()); + } + throw ase; // No, so rethrow original + } return joinedArray; }