commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1436044 - /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java
Date Mon, 21 Jan 2013 01:08:58 GMT
Author: sebb
Date: Mon Jan 21 01:08:58 2013
New Revision: 1436044

URL: http://svn.apache.org/viewvc?rev=1436044&view=rev
Log:
Javadoc
Remove unsafe @SuppressWarnings

Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java?rev=1436044&r1=1436043&r2=1436044&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/bag/AbstractMapBag.java
Mon Jan 21 01:08:58 2013
@@ -447,15 +447,17 @@ public abstract class AbstractMapBag<E> 
 
     /**
      * Returns an array of all of this bag's elements.
+     * If the input array has more elements than are in the bag,
+     * trailing elements will be set to null.
      * 
      * @param <T> the type of the array elements
      * @param array the array to populate
      * @return an array of all of this bag's elements
      */
-    @SuppressWarnings("unchecked")
     public <T> 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);
         }
 
@@ -464,6 +466,7 @@ public abstract class AbstractMapBag<E> 
         while (it.hasNext()) {
             final E current = it.next();
             for (int index = getCount(current); index > 0; index--) {
+                // TODO this is unsafe
                 array[i++] = (T) current;
             }
         }



Mime
View raw message