[COLLECTIONS-481] Use varargs parameter in CompositeSet.addComposited, fixed conflict resolution when using more than 1 Set as argument. Thanks to Hollis Waite.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1521262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4951344fb2
commit
c151913ae2
|
@ -46,6 +46,9 @@ Major changes since 3.2.1
|
|||
Changes since 4.0-alpha1
|
||||
------------------------
|
||||
|
||||
- [COLLECTIONS-481] No collision detection/resolution was performed when calling "CompositeSet#addComposited(...)"
|
||||
with more than one Set as argument. Also changed the the method with an array argument to use
|
||||
a varargs parameter. Thanks to Hollis Waite.
|
||||
- [COLLECTIONS-468] Renamed CompliantBag to CollectionBag.
|
||||
- [COLLECTIONS-475] Fixed conversion of timeout parameters in "PassiveExpiringMap".
|
||||
|
||||
|
@ -207,6 +210,9 @@ Changed classes / methods
|
|||
Fixed Bugs
|
||||
----------
|
||||
|
||||
o [COLLECTIONS-481] No collision detection/resolution was performed when calling "CompositeSet#addComposited(...)"
|
||||
with more than one Set as argument. Also changed the the method with an array argument to use
|
||||
a varargs parameter. Thanks to Hollis Waite.
|
||||
o [COLLECTIONS-475] Fixed conversion of timeout parameters in "PassiveExpiringMap".
|
||||
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
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
<body>
|
||||
|
||||
<release version="4.0" date="TBA" description="Next release">
|
||||
<action issue="COLLECTIONS-481" dev="tn" type="fix" due-to="Hollis Waite">
|
||||
No collision detection/resolution was performed when calling "CompositeSet#addComposited(...)"
|
||||
with more than one Set as argument. Also changed the the method with an array argument to use a
|
||||
varargs parameter.
|
||||
</action>
|
||||
<action issue="COLLECTIONS-475" dev="tn" type="fix">
|
||||
Fixed conversion of timeout parameters in "PassiveExpiringMap".
|
||||
</action>
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.commons.collections4.set;
|
|||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -338,6 +337,7 @@ public class CompositeSet<E> implements Set<E>, Serializable {
|
|||
* @param set the set to add
|
||||
* @throws IllegalArgumentException if a SetMutator is set, but fails to resolve a collision
|
||||
* @throws UnsupportedOperationException if there is no SetMutator set
|
||||
* @throws NullPointerException if {@code set} is null
|
||||
* @see SetMutator
|
||||
*/
|
||||
public synchronized void addComposited(final Set<E> set) {
|
||||
|
@ -365,8 +365,8 @@ public class CompositeSet<E> implements Set<E>, Serializable {
|
|||
* @param set2 the second Set to be appended to the composite
|
||||
*/
|
||||
public void addComposited(final Set<E> set1, final Set<E> set2) {
|
||||
all.add(set1);
|
||||
all.add(set2);
|
||||
addComposited(set1);
|
||||
addComposited(set2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -374,8 +374,10 @@ public class CompositeSet<E> implements Set<E>, Serializable {
|
|||
*
|
||||
* @param sets the Sets to be appended to the composite
|
||||
*/
|
||||
public void addComposited(final Set<E>[] sets) {
|
||||
all.addAll(Arrays.asList(sets));
|
||||
public void addComposited(final Set<E>... sets) {
|
||||
for (Set<E> set : sets) {
|
||||
addComposited(set);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -186,6 +186,7 @@ This release is <b>not</b> source or binary compatible with v3.x.
|
|||
|
||||
<center><h3>Bugfixes</h3></center>
|
||||
<ul>
|
||||
<li>Fixed collision detection/resolution when calling "CompositeSet#addComposited(...)" with more than one Set as argument.</li>
|
||||
<li>Fixed conversion of timeout parameters in "PassiveExpiringMap".</li>
|
||||
<li>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.</li>
|
||||
<li>Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately after a difference has been found. Thanks to Adrian Nistor.</li>
|
||||
|
|
|
@ -150,6 +150,29 @@ public class CompositeSetTest<E> extends AbstractSetTest<E> {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testAddCompositedCollision() {
|
||||
final HashSet<E> set1 = new HashSet<E>();
|
||||
set1.add((E) "1");
|
||||
set1.add((E) "2");
|
||||
set1.add((E) "3");
|
||||
final HashSet<E> set2 = new HashSet<E>();
|
||||
set2.add((E) "4");
|
||||
final CompositeSet<E> set3 = new CompositeSet<E>(set1);
|
||||
try {
|
||||
set3.addComposited(set1, buildOne());
|
||||
fail("Expecting UnsupportedOperationException.");
|
||||
} catch (final UnsupportedOperationException ex) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
set3.addComposited(set1, buildOne(), buildTwo());
|
||||
fail("Expecting UnsupportedOperationException.");
|
||||
} catch (final UnsupportedOperationException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCompatibilityVersion() {
|
||||
return "4";
|
||||
|
|
Loading…
Reference in New Issue