Buggy code:
public abstract class AbstractBagTest < T > extends AbstractCollectionTest < T > { public AbstractBagTest ( final String testName ) { } @ Override public Collection < T > makeConfirmedCollection ( ) { } @ Override public Collection < T > makeConfirmedFullCollection ( ) { } @ Override public abstract Bag < T > makeObject ( ) { } @ Override public Bag < T > makeFullCollection ( ) { } @ Override public void resetEmpty ( ) { } @ Override public void resetFull ( ) { } @ Override public Bag < T > getCollection ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagAdd ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagEqualsSelf ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagRemove ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagRemoveAll ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagContains ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagContainsAll ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagSize ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagRetainAll ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagIterator ( ) { if ( ! ( AbstractBagTest . isAddSupported ( ) ) ) { return ; } final Bag < T > bag = makeObject ( ) ; bag . add ( ( ( T ) ( "A" ) ) ) ; bag . add ( ( ( T ) ( "A" ) ) ) ; bag . add ( ( ( T ) ( "B" ) ) ) ; assertEquals ( "Bag<seq2seq4repair_space>should<seq2seq4repair_space>have<seq2seq4repair_space>3<seq2seq4repair_space>items" , 3 , bag . size ( ) ) ; final Iterator < T > i = bag . iterator ( ) ; boolean foundA = false ; while ( i . hasNext ( ) ) { final String element = ( ( String ) ( i . next ( ) ) ) ; if ( element . equals ( "A" ) ) { <START_BUG> if ( foundA == false ) { <END_BUG> foundA = true ; } else { i . remove ( ) ; } } } assertTrue ( "Bag<seq2seq4repair_space>should<seq2seq4repair_space>still<seq2seq4repair_space>contain<seq2seq4repair_space>'A'" , bag . contains ( "A" ) ) ; assertEquals ( "Bag<seq2seq4repair_space>should<seq2seq4repair_space>have<seq2seq4repair_space>2<seq2seq4repair_space>items" , 2 , bag . size ( ) ) ; assertEquals ( "Bag<seq2seq4repair_space>should<seq2seq4repair_space>have<seq2seq4repair_space>1<seq2seq4repair_space>'A'" , 1 , bag . getCount ( "A" ) ) ; } @ SuppressWarnings ( "unchecked" ) public void testBagIteratorFail ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagIteratorFailNoMore ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagIteratorFailDoubleRemove ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagIteratorRemoveProtectsInvariants ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagToArray ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagToArrayPopulate ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagEquals ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagEqualsHashBag ( ) { } @ SuppressWarnings ( "unchecked" ) public void testBagHashCode ( ) { } public BulkTest bulkTestBagUniqueSet ( ) { } public class TestBagUniqueSet extends AbstractSetTest < T > { public TestBagUniqueSet ( ) { } @ Override public T [ ] getFullElements ( ) { } @ Override public T [ ] getOtherElements ( ) { } @ Override public Set < T > makeObject ( ) { } @ Override public Set < T > makeFullCollection ( ) { } @ Override public boolean isNullSupported ( ) { } @ Override public boolean isAddSupported ( ) { } @ Override public boolean isRemoveSupported ( ) { } @ Override public boolean isTestSerialization ( ) { } @ Override public void resetEmpty ( ) { } @ Override public void resetFull ( ) { } @ Override public void verify ( ) { } } public void testEmptyBagCompatibility ( ) throws IOException , ClassNotFoundException { } public void testFullBagCompatibility ( ) throws IOException , ClassNotFoundException { } }

Fix:
if ( ! foundA ) {