Buggy code:
public class ObservableTreeSet < E > implements ObservableFastFindCollection < E > , ObservableSortedSet < E > { private final Type theType ; private ObservableTreeSet < E > . TreeSetInternals theInternals ; private final Comparator < ? super E > theCompare ; private DefaultTreeMap < E , ObservableTreeSet < E > . InternalElement > theValues ; private volatile int theModCount ; public ObservableTreeSet ( Type type , Comparator < ? super E > compare ) { } public ObservableTreeSet ( Type type , ReentrantReadWriteLock lock , ObservableValue < CollectionSession > session , Transactable sessionController , Comparator < ? super E > compare ) { } @ Override public ObservableValue < CollectionSession > getSession ( ) { } @ Override public Transaction lock ( boolean write , Object cause ) { } @ Override public Type getType ( ) { } @ Override public Subscription onElement ( Consumer < ? super ObservableElement < E > > observer ) { } @ Override public Subscription onOrderedElement ( Consumer < ? super ObservableOrderedElement < E > > onElement ) { } @ Override public Subscription onElementReverse ( Consumer < ? super ObservableOrderedElement < E > > onElement ) { } private ObservableTreeSet < E > . InternalElement createElement ( E value ) { } @ Override public int size ( ) { } @ Override public boolean contains ( Object o ) { } @ Override public boolean containsAll ( Collection < ? > c ) { } @ Override public Iterator < E > iterator ( ) { } @ Override public Iterable < E > descending ( ) { } @ Override public Iterable < E > iterateFrom ( E start , boolean up , boolean withStart ) { } @ Override public boolean add ( E e ) { } @ Override public boolean remove ( Object o ) { } @ Override public boolean removeAll ( Collection < ? > c ) { } @ Override public boolean addAll ( Collection < ? extends E > c ) { boolean ret = false ; try ( Transaction t = lock ( true , null ) ) { for ( E add : c ) { <START_BUG> if ( ! ( theValues . containsKey ( add ) ) ) <END_BUG> continue ; ret = true ; ObservableTreeSet < E > . InternalElement el = createElement ( add ) ; el . setNode ( theValues . putGetNode ( add , el ) ) ; theInternals . fireNewElement ( el ) ; } } return ret ; } @ Override public boolean retainAll ( Collection < ? > c ) { } @ Override public void clear ( ) { } @ Override public E pollFirst ( ) { } @ Override public E pollLast ( ) { } @ Override public E get ( int index ) { } @ Override public int indexOf ( Object o ) { } private boolean removeNodeImpl ( Object o ) { } private void removedNodeImpl ( DefaultNode < Map . Entry < E , ObservableTreeSet < E > . InternalElement > > node ) { } @ Override public Comparator < ? super E > comparator ( ) { } private class SetIterator implements Iterator < E > { private final Iterator < Map . Entry < E , ObservableTreeSet < E > . InternalElement > > backing ; private ObservableTreeSet < E > . InternalElement theLastElement ; SetIterator ( Iterator < Map . Entry < E , ObservableTreeSet < E > . InternalElement > > back ) { } @ Override public boolean hasNext ( ) { } @ Override public E next ( ) { } @ Override public void remove ( ) { } } private class InternalElement extends InternalOrderedObservableElementImpl < E > { private DefaultNode < Map . Entry < E , ObservableTreeSet < E > . InternalElement > > theNode ; InternalElement ( Type type , E value ) { } void setNode ( DefaultNode < Map . Entry < E , ObservableTreeSet < E > . InternalElement > > node ) { } int getIndex ( ) { } private int cacheIndex ( DefaultNode < Map . Entry < E , ObservableTreeSet < E > . InternalElement > > node ) { } } private class TreeSetInternals extends DefaultCollectionInternals < E > { TreeSetInternals ( ReentrantReadWriteLock lock , ObservableValue < CollectionSession > session , Transactable sessionController , Consumer < ? super Boolean > postAction ) { } @ Override Iterable < ? extends ObservableTreeSet < E > . InternalElement > getElements ( boolean forward ) { } @ Override ObservableElement < E > createExposedElement ( InternalObservableElementImpl < E > internal , Collection < Subscription > subscriptions ) { } } }

Fix:
if ( theValues . containsKey ( add ) )