Author: tn Date: Mon Jun 24 20:04:16 2013 New Revision: 1496190 URL: http://svn.apache.org/r1496190 Log: [COLLECTIONS-474] Added sanity checks, javadoc clarification, changelog entry.
Modified: commons/proper/collections/trunk/RELEASE-NOTES.txt commons/proper/collections/trunk/src/changes/changes.xml commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java Modified: commons/proper/collections/trunk/RELEASE-NOTES.txt URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/RELEASE-NOTES.txt?rev=1496190&r1=1496189&r2=1496190&view=diff ============================================================================== --- commons/proper/collections/trunk/RELEASE-NOTES.txt (original) +++ commons/proper/collections/trunk/RELEASE-NOTES.txt Mon Jun 24 20:04:16 2013 @@ -192,6 +192,9 @@ Changed classes / methods Fixed Bugs ---------- + o [COLLECTIONS-474] ListOrderedMap#putAll(index, Object, Object) does not throw an exception anymore if the + map contains null values. Additionally added javadoc clarification on the supported bounds + for the index parameter. Thanks to Ning Chen. o [COLLECTIONS-472] Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately after a difference has been found. Thanks to Adrian Nistor. o [COLLECTIONS-461] Added additional clarification to javadoc of interface "Put" wrt return type of Modified: commons/proper/collections/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/changes/changes.xml?rev=1496190&r1=1496189&r2=1496190&view=diff ============================================================================== --- commons/proper/collections/trunk/src/changes/changes.xml (original) +++ commons/proper/collections/trunk/src/changes/changes.xml Mon Jun 24 20:04:16 2013 @@ -21,13 +21,10 @@ </properties> <body> - <release version="4.x" date="TBA" description="TBA"> + <release version="4.0" date="TBA" description="Next release"> <action issue="COLLECTIONS-474" dev="sebb" type="fix" due-to="Ning Chen "> Exception in ListOrderedMap#putAll if map contains null values. </action> - </release> - - <release version="4.0" date="TBA" description="Next release"> <action issue="COLLECTIONS-473" dev="tn" type="update" due-to="sebb"> Made field "collection" in class "AbstractCollectionDecorator" private and added setter "setCollection(Collection)" with scope protected to set the decorated collection Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java?rev=1496190&r1=1496189&r2=1496190&view=diff ============================================================================== --- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java (original) +++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/map/ListOrderedMap.java Mon Jun 24 20:04:16 2013 @@ -240,8 +240,12 @@ public class ListOrderedMap<K, V> * * @param index the index in the Map to start at. * @param map the Map containing the entries to be added. + * @throws IndexOutOfBoundsException if the index is out of range [0, size] */ public void putAll(int index, final Map<? extends K, ? extends V> map) { + if (index < 0 || index > insertOrder.size()) { + throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + insertOrder.size()); + } for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { final K key = entry.getKey(); final boolean contains = containsKey(key); @@ -437,10 +441,14 @@ public class ListOrderedMap<K, V> * @param key the key * @param value the value * @return the value previously mapped to the key - * @throws IndexOutOfBoundsException if the index is out of range + * @throws IndexOutOfBoundsException if the index is out of range [0, size] * @since 3.2 */ public V put(int index, final K key, final V value) { + if (index < 0 || index > insertOrder.size()) { + throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + insertOrder.size()); + } + final Map<K, V> m = decorated(); if (m.containsKey(key)) { final V result = m.remove(key);