FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
http://download.oracle.com/javase/6/docs/api/java/util/TreeSet.html#contains%28java.lang.Object%29 states that add(E) uses the equals method to determine whether two objects were equal. However, I have determined that it only uses compareTo, which does not make sense in this context. Originally, I had a compareTo that was inconsistent with the equals method because I was only using it to sort elements by a unique identifier. I put a print statement at the beginning of the equals method and it printed nothing for the 500+ times the add method for TreeSet had been run. Adding the following line to the compareTo method fixed this problem and made the TreeSet detect duplicates correctly: if (this.equals((Clause) o)) return 0;
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
make compareTo consistent with equals