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>
|
||||
<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">
|
||||
<action issue="COLLECTIONS-473" dev="tn" type="update" due-to="sebb">
|
||||
Made field "collection" in class "AbstractCollectionDecorator" private and added
|
||||
|
|
|
@ -239,12 +239,16 @@ public class ListOrderedMap<K, V>
|
|||
* the specified index.
|
||||
*
|
||||
* @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) {
|
||||
for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
||||
final V old = put(index, entry.getKey(), entry.getValue());
|
||||
if (old == null) {
|
||||
final K key = entry.getKey();
|
||||
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
|
||||
index++;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue