Wrong implementation of method retainAll in PersistentSet
---------------------------------------------------------
Key: HIBERNATE-75
URL:
http://jira.jboss.com/jira/browse/HIBERNATE-75
Project: Hibernate
Issue Type: Bug
Reporter: Andrey Peristyy
Assigned To: Steve Ebersole
The method from org.hibernate.collection.PersistentSet adds all elements from coll to the
current set. But it must retains only the elements in this set that are contained in the
specified collection. As it stated in javadoc for java.util.Set.
Method from PersistentSet:
public boolean retainAll(Collection coll) {
initialize( true );
if ( set.addAll( coll ) ) {
dirty();
return true;
}
else {
return false;
}
}
Correct implementation from java.util.AbstractCollection:
public boolean retainAll(Collection<?> c) {
boolean modified = false;
Iterator<E> e = iterator();
while (e.hasNext()) {
if (!c.contains(e.next())) {
e.remove();
modified = true;
}
}
return modified;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira