Buggy code:
public class TestFieldCache extends LuceneTestCase { private static IndexReader reader ; private static int NUM_DOCS ; private static int NUM_ORDS ; private static String [ ] unicodeStrings ; private static BytesRef [ ] [ ] multiValued ; private static Directory directory ; @ BeforeClass public static void beforeClass ( ) throws Exception { TestFieldCache . NUM_DOCS = atLeast ( 500 ) ; TestFieldCache . NUM_ORDS = atLeast ( 2 ) ; TestFieldCache . directory = newDirectory ( ) ; RandomIndexWriter writer = new RandomIndexWriter ( random , TestFieldCache . directory , newIndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . MockAnalyzer ( random ) ) . setMergePolicy ( newLogMergePolicy ( ) ) ) ; long theLong = Long . MAX_VALUE ; double theDouble = Double . MAX_VALUE ; byte theByte = Byte . MAX_VALUE ; short theShort = Short . MAX_VALUE ; int theInt = Integer . MAX_VALUE ; float theFloat = Float . MAX_VALUE ; TestFieldCache . unicodeStrings = new String [ TestFieldCache . NUM_DOCS ] ; TestFieldCache . multiValued = new BytesRef [ TestFieldCache . NUM_DOCS ] [ TestFieldCache . NUM_ORDS ] ; if ( VERBOSE ) { System . out . println ( "TEST:<seq2seq4repair_space>setUp" ) ; } for ( int i = 0 ; i < ( TestFieldCache . NUM_DOCS ) ; i ++ ) { Document doc = new Document ( ) ; doc . add ( newField ( "theLong" , String . valueOf ( ( theLong -- ) ) , TYPE_UNSTORED ) ) ; doc . add ( newField ( "theDouble" , String . valueOf ( ( theDouble -- ) ) , TYPE_UNSTORED ) ) ; doc . add ( newField ( "theByte" , String . valueOf ( ( theByte -- ) ) , TYPE_UNSTORED ) ) ; doc . add ( newField ( "theShort" , String . valueOf ( ( theShort -- ) ) , TYPE_UNSTORED ) ) ; doc . add ( newField ( "theInt" , String . valueOf ( ( theInt -- ) ) , TYPE_UNSTORED ) ) ; doc . add ( newField ( "theFloat" , String . valueOf ( ( theFloat -- ) ) , TYPE_UNSTORED ) ) ; if ( ( i % 2 ) == 0 ) { doc . add ( newField ( "sparse" , String . valueOf ( i ) , TYPE_UNSTORED ) ) ; } if ( ( i % 2 ) == 0 ) { <START_BUG> doc . add ( new NumericField ( "numInt" ) . setIntValue ( i ) ) ; <END_BUG> } if ( ( random . nextInt ( 40 ) ) != 17 ) { TestFieldCache . unicodeStrings [ i ] = TestFieldCache . generateString ( i ) ; doc . add ( newField ( "theRandomUnicodeString" , TestFieldCache . unicodeStrings [ i ] , TYPE_STORED ) ) ; } if ( ( random . nextInt ( 10 ) ) != 8 ) { for ( int j = 0 ; j < ( TestFieldCache . NUM_ORDS ) ; j ++ ) { String newValue = TestFieldCache . generateString ( i ) ; TestFieldCache . multiValued [ i ] [ j ] = new BytesRef ( newValue ) ; doc . add ( newField ( "theRandomUnicodeMultiValuedField" , newValue , TYPE_STORED ) ) ; } Arrays . sort ( TestFieldCache . multiValued [ i ] ) ; } writer . addDocument ( doc ) ; } TestFieldCache . reader = writer . getReader ( ) ; writer . close ( ) ; } @ AfterClass public static void afterClass ( ) throws Exception { } public void testInfoStream ( ) throws Exception { } public void test ( ) throws IOException { } public void testEmptyIndex ( ) throws Exception { } private static String generateString ( int i ) { } public void testDocsWithField ( ) throws Exception { } public void testGetDocsWithFieldThreadSafety ( ) throws Exception { } }

Fix:
doc . add ( new NumericField ( "numInt" , i ) ) ;