COLLECTIONS-474 Exception in ListOrderedMap#putAll if map contains null values
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1496182 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
62e69cf4f2
commit
7df57879c9
|
@ -21,6 +21,12 @@
|
||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<release version="4.x" date="TBA" description="TBA">
|
||||||
|
<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">
|
<release version="4.0" date="TBA" description="Next release">
|
||||||
<action issue="COLLECTIONS-473" dev="tn" type="update" due-to="sebb">
|
<action issue="COLLECTIONS-473" dev="tn" type="update" due-to="sebb">
|
||||||
Made field "collection" in class "AbstractCollectionDecorator" private and added
|
Made field "collection" in class "AbstractCollectionDecorator" private and added
|
||||||
|
|
|
@ -239,12 +239,16 @@ public class ListOrderedMap<K, V>
|
||||||
* the specified index.
|
* the specified index.
|
||||||
*
|
*
|
||||||
* @param index the index in the Map to start at.
|
* @param index the index in the Map to start at.
|
||||||
* @param map the Map containing the values to be added.
|
* @param map the Map containing the entries to be added.
|
||||||
*/
|
*/
|
||||||
public void putAll(int index, final Map<? extends K, ? extends V> map) {
|
public void putAll(int index, final Map<? extends K, ? extends V> map) {
|
||||||
for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
||||||
final V old = put(index, entry.getKey(), entry.getValue());
|
final K key = entry.getKey();
|
||||||
if (old == null) {
|
final boolean contains = containsKey(key);
|
||||||
|
// The return value of put is null if the key did not exist OR the value was null
|
||||||
|
// so it cannot be used to determine whether the key was added
|
||||||
|
put(index, entry.getKey(), entry.getValue());
|
||||||
|
if (!contains) {
|
||||||
// if no key was replaced, increment the index
|
// if no key was replaced, increment the index
|
||||||
index++;
|
index++;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue