Buggy code:
final class DocFieldProcessor extends DocConsumer { final DocFieldConsumer consumer ; final StoredFieldsWriter fieldsWriter ; DocFieldProcessorPerField [ ] fields = new DocFieldProcessorPerField [ 1 ] ; int fieldCount ; DocFieldProcessorPerField [ ] fieldHash = new DocFieldProcessorPerField [ 2 ] ; int hashMask = 1 ; int totalFieldCount ; float docBoost ; int fieldGen ; final DocState docState ; public DocFieldProcessor ( DocumentsWriterPerThread docWriter , DocFieldConsumer consumer ) { } @ Override public void flush ( SegmentWriteState state ) throws IOException { } @ Override public void abort ( ) { } @ Override public boolean freeRAM ( ) { } public Collection < DocFieldConsumerPerField > fields ( ) { } @ Override void doAfterFlush ( ) { } private void rehash ( ) { } @ Override public void processDocument ( FieldInfos fieldInfos ) throws IOException { } private static final Comparator < DocFieldProcessorPerField > fieldsComp = new Comparator < DocFieldProcessorPerField > ( ) { public int compare ( DocFieldProcessorPerField o1 , DocFieldProcessorPerField o2 ) { } } ; @ Override void finishDocument ( ) throws IOException { } private static class DocValuesConsumerAndDocID { public int docID ; final DocValuesConsumer docValuesConsumer ; public DocValuesConsumerAndDocID ( DocValuesConsumer docValuesConsumer ) { } } private final Map < String , DocFieldProcessor . DocValuesConsumerAndDocID > docValues = new HashMap < String , DocFieldProcessor . DocValuesConsumerAndDocID > ( ) ; private final Map < Integer , PerDocConsumer > perDocConsumers = new HashMap < Integer , PerDocConsumer > ( ) ; DocValuesConsumer docValuesConsumer ( DocState docState , FieldInfo fieldInfo ) throws IOException { DocFieldProcessor . DocValuesConsumerAndDocID docValuesConsumerAndDocID = docValues . get ( fieldInfo . name ) ; if ( docValuesConsumerAndDocID != null ) { if ( ( docState . docID ) == ( docValuesConsumerAndDocID . docID ) ) { throw new IllegalArgumentException ( ( ( "IndexDocValuesField<seq2seq4repair_space>\"" + ( fieldInfo . name ) ) + "\"<seq2seq4repair_space>appears<seq2seq4repair_space>more<seq2seq4repair_space>than<seq2seq4repair_space>once<seq2seq4repair_space>in<seq2seq4repair_space>this<seq2seq4repair_space>document<seq2seq4repair_space>(only<seq2seq4repair_space>one<seq2seq4repair_space>value<seq2seq4repair_space>is<seq2seq4repair_space>allowed,<seq2seq4repair_space>per<seq2seq4repair_space>field)" ) ) ; } assert ( docValuesConsumerAndDocID . docID ) < ( docState . docID ) ; docValuesConsumerAndDocID . docID = docState . docID ; return docValuesConsumerAndDocID . docValuesConsumer ; } PerDocConsumer perDocConsumer = perDocConsumers . get ( 0 ) ; if ( perDocConsumer == null ) { <START_BUG> PerDocWriteState perDocWriteState = docState . docWriter . newPerDocWriteState ( 0 ) ; <END_BUG> DocValuesFormat dvFormat = docState . docWriter . codec . docValuesFormat ( ) ; perDocConsumer = dvFormat . docsConsumer ( perDocWriteState ) ; perDocConsumers . put ( 0 , perDocConsumer ) ; } boolean success = false ; DocValuesConsumer docValuesConsumer = null ; try { docValuesConsumer = perDocConsumer . addValuesField ( fieldInfo ) ; fieldInfo . commitDocValues ( ) ; success = true ; } finally { if ( ! success ) { fieldInfo . revertUncommitted ( ) ; } } docValuesConsumerAndDocID = new DocFieldProcessor . DocValuesConsumerAndDocID ( docValuesConsumer ) ; docValuesConsumerAndDocID . docID = docState . docID ; docValues . put ( fieldInfo . name , docValuesConsumerAndDocID ) ; return docValuesConsumer ; } }

Fix:
PerDocWriteState perDocWriteState = docState . docWriter . newPerDocWriteState ( "" ) ;