[ https://issues.apache.org/jira/browse/COLLECTIONS-444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Vahrst updated COLLECTIONS-444: -------------------------------------- Description: I found this bug during my work on issue COLLECTIONS-310 : When you 'set' an element to a position that contains this element, it is removed from the internal set. This leads to the situation that - invocing get() returns the element - invocing contains() returns false. Extending the existing test method for set: {code} public void testSet() { final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); // Duplicate element final E obj1 = (E) new Integer(1); final E obj2 = (E) new Integer(2); final E obj3 = (E) new Integer(3); lset.add(obj1); lset.add(obj2); lset.set(0, obj1); assertEquals(2, lset.size()); assertSame(obj1, lset.get(0)); assertSame(obj2, lset.get(1)); assertTrue(lset.contains(obj1)); // fails ! assertTrue(lset.contains(obj2)); {code} was: I found this bug during my work on issue COLLECTIONS-310 : When you 'set' an element to a position that contains this element, it is removed from the internal set. This leads to the situation that - invocing get() returns the element - invocing contains() returns false. Extending the existing test method for set: {code} public void testSet() { final SetUniqueList<E> lset = new SetUniqueList<E>(new ArrayList<E>(), new HashSet<E>()); // Duplicate element final E obj1 = (E) new Integer(1); final E obj2 = (E) new Integer(2); final E obj3 = (E) new Integer(3); lset.add(obj1); lset.add(obj2); lset.set(0, obj1); assertEquals(2, lset.size()); assertSame(obj1, lset.get(0)); assertSame(obj2, lset.get(1)); assertTrue(lset.contains(obj1)); // fails ! assertTrue(lset.contains(obj2)); {code} > SetUniqueList may become inconsistent > ------------------------------------- > > Key: COLLECTIONS-444 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-444 > Project: Commons Collections > Issue Type: Bug > Components: List > Affects Versions: 3.2.1 > Reporter: Thomas Vahrst > > I found this bug during my work on issue COLLECTIONS-310 : > When you 'set' an element to a position that contains this element, it is > removed from the internal set. This leads to the situation that > - invocing get() returns the element > - invocing contains() returns false. > Extending the existing test method for set: > {code} > public void testSet() { > final SetUniqueList<E> lset = new SetUniqueList<E>(new > ArrayList<E>(), new HashSet<E>()); > // Duplicate element > final E obj1 = (E) new Integer(1); > final E obj2 = (E) new Integer(2); > final E obj3 = (E) new Integer(3); > lset.add(obj1); > lset.add(obj2); > lset.set(0, obj1); > assertEquals(2, lset.size()); > assertSame(obj1, lset.get(0)); > assertSame(obj2, lset.get(1)); > assertTrue(lset.contains(obj1)); // fails ! > assertTrue(lset.contains(obj2)); > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira