[COLLECTIONS-710] NullPointerExceptions in CompositeCollection,
CompositeSet, and CompositeMap.
This commit is contained in:
parent
036bbf34d2
commit
c46666c5dd
|
@ -20,6 +20,11 @@
|
|||
<title>Commons Collections Changes</title>
|
||||
</properties>
|
||||
<body>
|
||||
<release version="4.3.1" date="2019-MM-DD" description="Maintenance release.">
|
||||
<action issue="COLLECTIONS-710" dev="ggregory" type="fix" due-to="Yu Shi, Gary Gregory">
|
||||
NullPointerExceptions in CompositeCollection, CompositeSet, and CompositeMap.
|
||||
</action>
|
||||
</release>
|
||||
<release version="4.3" date="2018-12-21" description="Update from Java 7 to Java 8, bug fixes, and small changes.">
|
||||
<action issue="COLLECTIONS-691" dev="kinow" type="fix" due-to="Eitan Adler">
|
||||
Use boolean operator for boolean result.
|
||||
|
|
|
@ -132,19 +132,21 @@ public class CompositeMap<K, V> extends AbstractIterableMap<K, V> implements Ser
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public synchronized void addComposited(final Map<K, V> map) throws IllegalArgumentException {
|
||||
for (int i = composite.length - 1; i >= 0; --i) {
|
||||
final Collection<K> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
|
||||
if (intersect.size() != 0) {
|
||||
if (this.mutator == null) {
|
||||
throw new IllegalArgumentException("Key collision adding Map to CompositeMap");
|
||||
if (map != null) {
|
||||
for (int i = composite.length - 1; i >= 0; --i) {
|
||||
final Collection<K> intersect = CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
|
||||
if (intersect.size() != 0) {
|
||||
if (this.mutator == null) {
|
||||
throw new IllegalArgumentException("Key collision adding Map to CompositeMap");
|
||||
}
|
||||
this.mutator.resolveCollision(this, this.composite[i], map, intersect);
|
||||
}
|
||||
this.mutator.resolveCollision(this, this.composite[i], map, intersect);
|
||||
}
|
||||
final Map<K, V>[] temp = new Map[this.composite.length + 1];
|
||||
System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
|
||||
temp[temp.length - 1] = map;
|
||||
this.composite = temp;
|
||||
}
|
||||
final Map<K, V>[] temp = new Map[this.composite.length + 1];
|
||||
System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
|
||||
temp[temp.length - 1] = map;
|
||||
this.composite = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,6 +75,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo());
|
||||
final HashMap<K, V> three = new HashMap<>();
|
||||
three.put((K) "5", (V) "five");
|
||||
map.addComposited(null);
|
||||
map.addComposited(three);
|
||||
assertTrue(map.containsKey("5"));
|
||||
try {
|
||||
|
@ -90,6 +91,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo());
|
||||
final HashMap<K, V> three = new HashMap<>();
|
||||
three.put((K) "5", (V) "five");
|
||||
map.addComposited(null);
|
||||
map.addComposited(three);
|
||||
assertTrue(map.containsKey("5"));
|
||||
|
||||
|
@ -106,6 +108,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo());
|
||||
final HashMap<K, V> three = new HashMap<>();
|
||||
three.put((K) "5", (V) "five");
|
||||
map.addComposited(null);
|
||||
map.addComposited(three);
|
||||
assertTrue(map.containsKey("5"));
|
||||
|
||||
|
@ -119,6 +122,7 @@ public class CompositeMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
final CompositeMap<K, V> map = new CompositeMap<>(buildOne(), buildTwo());
|
||||
final HashMap<K, V> three = new HashMap<>();
|
||||
three.put((K) "5", (V) "five");
|
||||
map.addComposited(null);
|
||||
map.addComposited(three);
|
||||
assertTrue(map.containsKey("5"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue