From 8106e483345dc343067d22d33a2e6bbacc141c47 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Mon, 25 Feb 2013 22:18:22 +0000 Subject: [PATCH] Fix TODO by documenting the possible exceptions, similar to e.g. java.util.ArrayList. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1449929 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/collections/bag/AbstractMapBag.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java b/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java index 9aca5afc1..edf9015ff 100644 --- a/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java +++ b/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java @@ -453,11 +453,14 @@ public abstract class AbstractMapBag implements Bag { * @param the type of the array elements * @param array the array to populate * @return an array of all of this bag's elements + * @throws ArrayStoreException if the runtime type of the specified array is not + * a supertype of the runtime type of the elements in this list + * @throws NullPointerException if the specified array is null */ + @SuppressWarnings("unchecked") public T[] toArray(T[] array) { final int size = size(); if (array.length < size) { - // This is safe, both are type T array = (T[]) Array.newInstance(array.getClass().getComponentType(), size); } @@ -466,7 +469,6 @@ public abstract class AbstractMapBag implements Bag { while (it.hasNext()) { final E current = it.next(); for (int index = getCount(current); index > 0; index--) { - // TODO this is unsafe array[i++] = (T) current; } }