This is an automated email from the ASF dual-hosted git repository. vladimirsitnikov pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/calcite.git
commit ad164ededa78a4b5383e636006e41ed98409ba7b Author: Vladimir Sitnikov <sitnikov.vladi...@gmail.com> AuthorDate: Fri Sep 4 23:31:06 2020 +0300 [CALCITE-4227] ImmutableIntList#toArray(Integer[]) should support arguments larger than the collection itself --- core/src/main/java/org/apache/calcite/util/ImmutableIntList.java | 2 +- core/src/test/java/org/apache/calcite/util/UtilTest.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/calcite/util/ImmutableIntList.java b/core/src/main/java/org/apache/calcite/util/ImmutableIntList.java index 46f32b5..e0f8e4c 100644 --- a/core/src/main/java/org/apache/calcite/util/ImmutableIntList.java +++ b/core/src/main/java/org/apache/calcite/util/ImmutableIntList.java @@ -151,7 +151,7 @@ public class ImmutableIntList extends FlatLists.AbstractFlatList<Integer> { } if ((Class) a.getClass() == Integer[].class) { final Integer[] integers = (Integer[]) a; - for (int i = 0; i < integers.length; i++) { + for (int i = 0; i < size; i++) { integers[i] = ints[i]; } } else { diff --git a/core/src/test/java/org/apache/calcite/util/UtilTest.java b/core/src/test/java/org/apache/calcite/util/UtilTest.java index e681446..98f99b4 100644 --- a/core/src/test/java/org/apache/calcite/util/UtilTest.java +++ b/core/src/test/java/org/apache/calcite/util/UtilTest.java @@ -1153,6 +1153,10 @@ class UtilTest { assertThat(list2.appendAll(list), sameInstance(list2)); //noinspection CollectionAddedToSelf assertThat(list2.appendAll(list2), is(Arrays.asList(1, 3, 5, 1, 3, 5))); + assertThat( + Arrays.toString(ImmutableIntList.of(1).toArray(new Integer[]{5, 6, 7})), + is("[1, null, 7]") + ); } /** Unit test for {@link IdPair}. */