Buggy code:
public class TestStressIndexing2 extends LuceneTestCase { static int maxFields = 4 ; static int bigFieldSize = 10 ; static boolean sameFieldOrder = false ; static int mergeFactor = 3 ; static int maxBufferedDocs = 3 ; static int seed = 0 ; public class MockIndexWriter extends IndexWriter { public MockIndexWriter ( Directory dir , IndexWriterConfig conf ) throws IOException { } @ Override boolean testPoint ( String name ) { } } public void testRandomIWReader ( ) throws Throwable { } public void testRandom ( ) throws Throwable { } public void testMultiConfig ( ) throws Throwable { } static Term idTerm = new Term ( "id" , "" ) ; TestStressIndexing2 . IndexingThread [ ] threads ; static Comparator < IndexableField > fieldNameComparator = new Comparator < IndexableField > ( ) { public int compare ( IndexableField o1 , IndexableField o2 ) { } } ; public static class DocsAndWriter { Map < String , Document > docs ; IndexWriter writer ; } public TestStressIndexing2 . DocsAndWriter indexRandomIWReader ( int nThreads , int iterations , int range , Directory dir ) throws IOException , InterruptedException { } public Map < String , Document > indexRandom ( int nThreads , int iterations , int range , Directory dir , int maxThreadStates , boolean doReaderPooling ) throws IOException , InterruptedException { } public static void indexSerial ( Random random , Map < String , Document > docs , Directory dir ) throws IOException { } public static void verifyEquals ( Random r , DirectoryReader r1 , Directory dir2 , String idField ) throws Throwable { } public static void verifyEquals ( Directory dir1 , Directory dir2 , String idField ) throws Throwable { } private static void printDocs ( DirectoryReader r ) throws Throwable { } public static void verifyEquals ( DirectoryReader r1 , DirectoryReader r2 , String idField ) throws Throwable { } public static void verifyEquals ( Document d1 , Document d2 ) { } public static void verifyEquals ( Fields d1 , Fields d2 ) throws IOException { if ( d1 == null ) { <START_BUG> assertTrue ( ( ( d2 == null ) || ( ( d2 . getUniqueFieldCount ( ) ) == 0 ) ) ) ; <END_BUG> return ; } assertTrue ( ( d2 != null ) ) ; FieldsEnum fieldsEnum1 = d1 . iterator ( ) ; FieldsEnum fieldsEnum2 = d2 . iterator ( ) ; String field1 ; while ( ( field1 = fieldsEnum1 . next ( ) ) != null ) { String field2 = fieldsEnum2 . next ( ) ; assertEquals ( field1 , field2 ) ; Terms terms1 = fieldsEnum1 . terms ( ) ; assertNotNull ( terms1 ) ; TermsEnum termsEnum1 = terms1 . iterator ( null ) ; Terms terms2 = fieldsEnum2 . terms ( ) ; assertNotNull ( terms2 ) ; TermsEnum termsEnum2 = terms2 . iterator ( null ) ; DocsAndPositionsEnum dpEnum1 = null ; DocsAndPositionsEnum dpEnum2 = null ; DocsEnum dEnum1 = null ; DocsEnum dEnum2 = null ; BytesRef term1 ; while ( ( term1 = termsEnum1 . next ( ) ) != null ) { BytesRef term2 = termsEnum2 . next ( ) ; assertEquals ( term1 , term2 ) ; assertEquals ( termsEnum1 . totalTermFreq ( ) , termsEnum2 . totalTermFreq ( ) ) ; dpEnum1 = termsEnum1 . docsAndPositions ( null , dpEnum1 , false ) ; dpEnum2 = termsEnum2 . docsAndPositions ( null , dpEnum2 , false ) ; if ( dpEnum1 != null ) { assertNotNull ( dpEnum2 ) ; int docID1 = dpEnum1 . nextDoc ( ) ; dpEnum2 . nextDoc ( ) ; assertTrue ( ( docID1 != ( DocIdSetIterator . NO_MORE_DOCS ) ) ) ; int freq1 = dpEnum1 . freq ( ) ; int freq2 = dpEnum2 . freq ( ) ; assertEquals ( freq1 , freq2 ) ; OffsetAttribute offsetAtt1 = ( dpEnum1 . attributes ( ) . hasAttribute ( OffsetAttribute . class ) ) ? dpEnum1 . attributes ( ) . getAttribute ( OffsetAttribute . class ) : null ; OffsetAttribute offsetAtt2 = ( dpEnum2 . attributes ( ) . hasAttribute ( OffsetAttribute . class ) ) ? dpEnum2 . attributes ( ) . getAttribute ( OffsetAttribute . class ) : null ; if ( offsetAtt1 != null ) { assertNotNull ( offsetAtt2 ) ; } else { assertNull ( offsetAtt2 ) ; } for ( int posUpto = 0 ; posUpto < freq1 ; posUpto ++ ) { int pos1 = dpEnum1 . nextPosition ( ) ; int pos2 = dpEnum2 . nextPosition ( ) ; assertEquals ( pos1 , pos2 ) ; if ( offsetAtt1 != null ) { assertEquals ( offsetAtt1 . startOffset ( ) , offsetAtt2 . startOffset ( ) ) ; assertEquals ( offsetAtt1 . endOffset ( ) , offsetAtt2 . endOffset ( ) ) ; } } assertEquals ( NO_MORE_DOCS , dpEnum1 . nextDoc ( ) ) ; assertEquals ( NO_MORE_DOCS , dpEnum2 . nextDoc ( ) ) ; } else { dEnum1 = _TestUtil . docs ( random , termsEnum1 , null , dEnum1 , true ) ; dEnum2 = _TestUtil . docs ( random , termsEnum2 , null , dEnum2 , true ) ; assertNotNull ( dEnum1 ) ; assertNotNull ( dEnum2 ) ; int docID1 = dEnum1 . nextDoc ( ) ; dEnum2 . nextDoc ( ) ; assertTrue ( ( docID1 != ( DocIdSetIterator . NO_MORE_DOCS ) ) ) ; int freq1 = dEnum1 . freq ( ) ; int freq2 = dEnum2 . freq ( ) ; assertEquals ( freq1 , freq2 ) ; assertEquals ( NO_MORE_DOCS , dEnum1 . nextDoc ( ) ) ; assertEquals ( NO_MORE_DOCS , dEnum2 . nextDoc ( ) ) ; } } assertNull ( termsEnum2 . next ( ) ) ; } assertNull ( fieldsEnum2 . next ( ) ) ; } private class IndexingThread extends Thread { IndexWriter w ; int base ; int range ; int iterations ;

Fix:
assertTrue ( ( ( d2 == null ) || ( ( d2 . size ( ) ) == 0 ) ) ) ;