Author: tn
Date: Mon Sep 9 19:38:49 2013
New Revision: 1521262
URL: http://svn.apache.org/r1521262
Log:
[COLLECTIONS-481] Use varargs parameter in CompositeSet.addComposited, fixed
conflict resolution when using more than 1 Set as argument. Thanks to Hollis
Waite.
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/set/CompositeSet.java
commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java
Modified: commons/proper/collections/trunk/RELEASE-NOTES.txt
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/RELEASE-NOTES.txt?rev=1521262&r1=1521261&r2=1521262&view=diff
==============================================================================
--- commons/proper/collections/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/collections/trunk/RELEASE-NOTES.txt Mon Sep 9 19:38:49 2013
@@ -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
Modified: commons/proper/collections/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/changes/changes.xml?rev=1521262&r1=1521261&r2=1521262&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/changes/changes.xml (original)
+++ commons/proper/collections/trunk/src/changes/changes.xml Mon Sep 9
19:38:49 2013
@@ -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>
Modified:
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/set/CompositeSet.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/set/CompositeSet.java?rev=1521262&r1=1521261&r2=1521262&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/set/CompositeSet.java
(original)
+++
commons/proper/collections/trunk/src/main/java/org/apache/commons/collections4/set/CompositeSet.java
Mon Sep 9 19:38:49 2013
@@ -19,7 +19,6 @@ package org.apache.commons.collections4.
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
* @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
* @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
*
* @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);
+ }
}
/**
Modified: commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml?rev=1521262&r1=1521261&r2=1521262&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml (original)
+++ commons/proper/collections/trunk/src/site/xdoc/release_4_0.xml Mon Sep 9
19:38:49 2013
@@ -186,6 +186,7 @@ This release is <b>not</b> source or bin
<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>
Modified:
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java?rev=1521262&r1=1521261&r2=1521262&view=diff
==============================================================================
---
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java
(original)
+++
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/set/CompositeSetTest.java
Mon Sep 9 19:38:49 2013
@@ -150,6 +150,29 @@ public class CompositeSetTest<E> extends
}
}
+ @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";