Buggy code:
@ SuppressCodecs ( "Lucene3x" ) public class TestTypePromotion extends LuceneTestCase { private static EnumSet < Type > INTEGERS = EnumSet . of ( VAR_INTS , FIXED_INTS_16 , FIXED_INTS_32 , FIXED_INTS_64 , FIXED_INTS_8 ) ; private static EnumSet < Type > FLOATS = EnumSet . of ( FLOAT_32 , FLOAT_64 , FIXED_INTS_8 ) ; private static EnumSet < Type > UNSORTED_BYTES = EnumSet . of ( BYTES_FIXED_DEREF , BYTES_FIXED_STRAIGHT , BYTES_VAR_STRAIGHT , BYTES_VAR_DEREF ) ; private static EnumSet < Type > SORTED_BYTES = EnumSet . of ( BYTES_FIXED_SORTED , BYTES_VAR_SORTED ) ; public Type randomValueType ( EnumSet < Type > typeEnum , Random random ) { } private static enum TestType { Int , Float , Byte ; } private void runTest ( EnumSet < Type > types , TestTypePromotion . TestType type ) throws IOException , CorruptIndexException { } private void assertValues ( TestTypePromotion . TestType type , Directory dir , long [ ] values , Type [ ] sourceType ) throws IOException , CorruptIndexException { } public void index ( IndexWriter writer , Type valueType , long [ ] values , Type [ ] sourceTypes , int offset , int num ) throws IOException , CorruptIndexException { final Field valField ; if ( VERBOSE ) { System . out . println ( ( ( ( ( ( "TEST:<seq2seq4repair_space>add<seq2seq4repair_space>docs<seq2seq4repair_space>" + offset ) + "-" ) + ( offset + num ) ) + "<seq2seq4repair_space>valType=" ) + valueType ) ) ; } switch ( valueType ) { case VAR_INTS : valField = new PackedLongDocValuesField ( "promote" , ( ( long ) ( 0 ) ) ) ; break ; case FIXED_INTS_8 : valField = new ByteDocValuesField ( "promote" , ( ( byte ) ( 0 ) ) ) ; break ; case FIXED_INTS_16 : valField = new ShortDocValuesField ( "promote" , ( ( short ) ( 0 ) ) ) ; break ; case FIXED_INTS_32 : valField = new IntDocValuesField ( "promote" , 0 ) ; break ; case FIXED_INTS_64 : valField = new LongDocValuesField ( "promote" , ( ( byte ) ( 0 ) ) ) ; break ; case FLOAT_32 : valField = new FloatDocValuesField ( "promote" , 0.0F ) ; break ; case FLOAT_64 : valField = new DoubleDocValuesField ( "promote" , 0.0 ) ; break ; case BYTES_FIXED_STRAIGHT : valField = new org . apache . lucene . document . StraightBytesDocValuesField ( "promote" , new BytesRef ( ) , true ) ; break ; case BYTES_VAR_STRAIGHT : valField = new org . apache . lucene . document . StraightBytesDocValuesField ( "promote" , new BytesRef ( ) , false ) ; break ; case BYTES_FIXED_DEREF : valField = new org . apache . lucene . document . DerefBytesDocValuesField ( "promote" , new BytesRef ( ) , true ) ; break ; case BYTES_VAR_DEREF : valField = new org . apache . lucene . document . DerefBytesDocValuesField ( "promote" , new BytesRef ( ) , false ) ; break ; case BYTES_FIXED_SORTED : valField = new org . apache . lucene . document . SortedBytesDocValuesField ( "promote" , new BytesRef ( ) , true ) ; break ; case BYTES_VAR_SORTED : valField = new org . apache . lucene . document . SortedBytesDocValuesField ( "promote" , new BytesRef ( ) , false ) ; break ; default : throw new IllegalStateException ( ( "unknown<seq2seq4repair_space>Type:<seq2seq4repair_space>" + valueType ) ) ; } for ( int i = offset ; i < ( offset + num ) ; i ++ ) { Document doc = new Document ( ) ; <START_BUG> doc . add ( new Field ( "id" , ( i + "" ) , TextField . TYPE_STORED ) ) ; <END_BUG> sourceTypes [ i ] = valueType ; switch ( valueType ) { case VAR_INTS : values [ i ] = random ( ) . nextInt ( ) ; valField . setLongValue ( values [ i ] ) ; break ; case FIXED_INTS_16 : values [ i ] = random ( ) . nextInt ( Short . MAX_VALUE ) ; valField . setShortValue ( ( ( short ) ( values [ i ] ) ) ) ; break ; case FIXED_INTS_32 : values [ i ] = random ( ) . nextInt ( ) ; valField . setIntValue ( ( ( int ) ( values [ i ] ) ) ) ; break ; case FIXED_INTS_64 : values [ i ] = random ( ) . nextLong ( ) ; valField . setLongValue ( values [ i ] ) ; break ; case FLOAT_64 : final double nextDouble = random ( ) . nextDouble ( ) ; values [ i ] = Double . doubleToRawLongBits ( nextDouble ) ; valField . setDoubleValue ( nextDouble ) ; break ; case FLOAT_32 : final float nextFloat = random ( ) . nextFloat ( ) ; values [ i ] = Double . doubleToRawLongBits ( nextFloat ) ; valField . setFloatValue ( nextFloat ) ; break ; case FIXED_INTS_8 : values [ i ] = ( ( byte ) ( i ) ) ; valField . setByteValue ( ( ( byte ) ( values [ i ] ) ) ) ; break ; case BYTES_FIXED_DEREF : case BYTES_FIXED_SORTED : case BYTES_FIXED_STRAIGHT : values [ i ] = random ( ) . nextLong ( ) ; byte [ ] bytes = new byte [ 8 ] ; ByteArrayDataOutput out = new ByteArrayDataOutput ( bytes , 0 , 8 ) ; out . writeLong ( values [ i ] ) ; valField . setBytesValue ( new BytesRef ( bytes ) ) ; break ; case BYTES_VAR_DEREF : case BYTES_VAR_SORTED : case BYTES_VAR_STRAIGHT : byte [ ] lbytes = new byte [ 8 ] ; ByteArrayDataOutput lout = new ByteArrayDataOutput ( lbytes , 0 , 8 ) ; final int len ; if ( random ( ) . nextBoolean ( ) ) { values [ i ] = random ( ) . nextInt ( ) ;

Fix:
doc . add ( new org . apache . lucene . document . TextField ( "id" , ( i + "" ) , Store . YES ) ) ;