From 1fb9183c706a8d660b856e9d8e66525525327418 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Wed, 28 Dec 2022 16:20:57 -0500 Subject: [PATCH] Use Arrays.copyOf() --- .../org/apache/commons/collections4/map/CompositeMap.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java index 2f893979d..a5c0c44cf 100644 --- a/src/main/java/org/apache/commons/collections4/map/CompositeMap.java +++ b/src/main/java/org/apache/commons/collections4/map/CompositeMap.java @@ -17,6 +17,7 @@ package org.apache.commons.collections4.map; import java.io.Serializable; +import java.util.Arrays; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -132,7 +133,6 @@ public class CompositeMap extends AbstractIterableMap implements Ser * @throws IllegalArgumentException if there is a key collision and there is no * MapMutator set to handle it. */ - @SuppressWarnings("unchecked") public synchronized void addComposited(final Map map) throws IllegalArgumentException { if (map != null) { for (int i = composite.length - 1; i >= 0; --i) { @@ -144,8 +144,7 @@ public class CompositeMap extends AbstractIterableMap implements Ser this.mutator.resolveCollision(this, this.composite[i], map, intersect); } } - final Map[] temp = new Map[this.composite.length + 1]; - System.arraycopy(this.composite, 0, temp, 0, this.composite.length); + final Map[] temp = Arrays.copyOf(this.composite, this.composite.length + 1); temp[temp.length - 1] = map; this.composite = temp; }