mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix bug
This commit is contained in:
parent
1d32b0862d
commit
73bca54b54
@ -348,6 +348,11 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
Array.set(buffer, index, value);
|
||||
return buffer;
|
||||
} else {
|
||||
if(ArrayUtil.isEmpty(buffer)){
|
||||
final T[] values = newArray(value.getClass(), 1);
|
||||
values[0] = value;
|
||||
return append(buffer, values);
|
||||
}
|
||||
return append(buffer, value);
|
||||
}
|
||||
}
|
||||
|
@ -527,4 +527,11 @@ public class ArrayUtilTest {
|
||||
result = ArrayUtil.replace(g, 0, h);
|
||||
Assert.assertArrayEquals(g, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setOrAppendTest(){
|
||||
String[] arr = new String[0];
|
||||
String[] newArr = ArrayUtil.setOrAppend(arr, 0, "Good");// ClassCastException
|
||||
Assert.assertArrayEquals(new String[]{"Good"}, newArr);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user