Buggy code:
final class DocumentsWriter { final AtomicLong bytesUsed = new AtomicLong ( 0 ) ; IndexWriter writer ; Directory directory ; String segment ; private int nextDocID ; private int numDocs ; private DocumentsWriterThreadState [ ] threadStates = new DocumentsWriterThreadState [ 0 ] ; private final HashMap < Thread , DocumentsWriterThreadState > threadBindings = new HashMap < Thread , DocumentsWriterThreadState > ( ) ; boolean bufferIsFull ; private boolean aborting ; PrintStream infoStream ; SimilarityProvider similarityProvider ; private final int maxThreadStates ; private BufferedDeletes pendingDeletes = new BufferedDeletes ( false ) ; static class DocState { DocumentsWriter docWriter ; Analyzer analyzer ; PrintStream infoStream ; SimilarityProvider similarityProvider ; int docID ; Document doc ; String maxTermPrefix ; public boolean testPoint ( String name ) { } public void clear ( ) { } } abstract static class DocWriter { DocumentsWriter . DocWriter next ; int docID ; abstract void finish ( ) throws IOException { } abstract void abort ( ) { } abstract long sizeInBytes ( ) { } void setNext ( DocumentsWriter . DocWriter next ) { } } DocumentsWriter . PerDocBuffer newPerDocBuffer ( ) { } @ SuppressWarnings ( "serial" ) class PerDocBuffer extends RAMFile { @ Override protected byte [ ] newBuffer ( int size ) { } synchronized void recycle ( ) { } } abstract static class IndexingChain { abstract DocConsumer getChain ( DocumentsWriter documentsWriter ) { } } static final DocumentsWriter . IndexingChain defaultIndexingChain = new DocumentsWriter . IndexingChain ( ) { @ Override DocConsumer getChain ( DocumentsWriter documentsWriter ) { } } ; final DocConsumer consumer ; private long ramBufferSize = ( ( long ) ( ( ( IndexWriterConfig . DEFAULT_RAM_BUFFER_SIZE_MB ) * 1024 ) * 1024 ) ) ; private long waitQueuePauseBytes = ( ( long ) ( ( ramBufferSize ) * 0.1 ) ) ; private long waitQueueResumeBytes = ( ( long ) ( ( ramBufferSize ) * 0.05 ) ) ; private long freeLevel = ( ( long ) ( ( ( ( IndexWriterConfig . DEFAULT_RAM_BUFFER_SIZE_MB ) * 1024 ) * 1024 ) * 0.95 ) ) ; private int maxBufferedDocs = IndexWriterConfig . DEFAULT_MAX_BUFFERED_DOCS ; private boolean closed ; private final FieldInfos fieldInfos ; private final BufferedDeletesStream bufferedDeletesStream ; private final FlushControl flushControl ; DocumentsWriter ( Directory directory , IndexWriter writer , DocumentsWriter . IndexingChain indexingChain , int maxThreadStates , FieldInfos fieldInfos , BufferedDeletesStream bufferedDeletesStream ) throws IOException { } synchronized void deleteDocID ( int docIDUpto ) { } boolean deleteQueries ( Query ... queries ) { } boolean deleteQuery ( Query query ) { } boolean deleteTerms ( Term ... terms ) { } boolean deleteTerm ( Term term , boolean skipWait ) { } public FieldInfos getFieldInfos ( ) { } synchronized void setInfoStream ( PrintStream infoStream ) { } synchronized void setSimilarityProvider ( SimilarityProvider similarity ) { } synchronized void setRAMBufferSizeMB ( double mb ) { } synchronized double getRAMBufferSizeMB ( ) { } void setMaxBufferedDocs ( int count ) { } int getMaxBufferedDocs ( ) { } synchronized String getSegment ( ) { } synchronized int getNumDocs ( ) { } void message ( String message ) { } synchronized void setAborting ( ) { } synchronized void abort ( ) throws IOException { } private void doAfterFlush ( ) throws IOException { } private synchronized boolean allThreadsIdle ( ) { } synchronized boolean anyChanges ( ) { } public BufferedDeletes getPendingDeletes ( ) { } private void pushDeletes ( SegmentInfo newSegment , SegmentInfos segmentInfos ) { final long delGen = bufferedDeletesStream . getNextGen ( ) ; if ( pendingDeletes . any ( ) ) { if ( ( ( segmentInfos . size ( ) ) > 0 ) || ( newSegment != null ) ) { final FrozenBufferedDeletes packet = new FrozenBufferedDeletes ( pendingDeletes , delGen ) ; if ( ( infoStream ) != null ) { <START_BUG> message ( "flush:<seq2seq4repair_space>push<seq2seq4repair_space>buffered<seq2seq4repair_space>deletes" ) ; <END_BUG> } bufferedDeletesStream . push ( packet ) ; if ( ( infoStream ) != null ) { message ( ( "flush:<seq2seq4repair_space>delGen=" + ( packet . gen ) ) ) ; } if ( newSegment != null ) { newSegment . setBufferedDeletesGen ( packet . gen ) ; } } else { if ( ( infoStream ) != null ) { message ( "flush:<seq2seq4repair_space>drop<seq2seq4repair_space>buffered<seq2seq4repair_space>deletes:<seq2seq4repair_space>no<seq2seq4repair_space>segments" ) ; } } pendingDeletes . clear ( ) ; } else if ( newSegment != null ) { newSegment . setBufferedDeletesGen ( delGen ) ; } } public boolean anyDeletions ( ) { } synchronized SegmentInfo flush ( IndexWriter writer , IndexFileDeleter deleter , MergePolicy mergePolicy , SegmentInfos segmentInfos ) throws IOException { } synchronized void close ( ) { } synchronized DocumentsWriterThreadState getThreadState ( Document doc , Term delTerm ) throws IOException { } boolean addDocument ( Document doc , Analyzer analyzer ) throws IOException , CorruptIndexException { } boolean updateDocument ( Document doc , Analyzer analyzer , Term delTerm ) throws IOException , CorruptIndexException { } public synchronized void waitIdle ( ) { } synchronized void waitReady ( DocumentsWriterThreadState state ) { } private void finishDocument ( DocumentsWriterThreadState perThread , DocumentsWriter . DocWriter docWriter ) throws IOException { } synchronized void waitForWaitQueue ( ) { } private static class SkipDocWriter extends DocumentsWriter . DocWriter { @ Override void finish ( ) { } @ Override void abort ( ) { } @ Override long sizeInBytes ( ) { } } final DocumentsWriter . SkipDocWriter skipDocWriter = new DocumentsWriter . SkipDocWriter ( ) ; NumberFormat nf = NumberFormat . getInstance ( ) ; static final int BYTE_BLOCK_NOT_MASK = ~ ( BYTE_BLOCK_MASK ) ; static final int MAX_TERM_LENGTH_UTF8 = ( BYTE_BLOCK_SIZE ) - 2 ; static final int INT_BLOCK_SHIFT = 13 ; static final int INT_BLOCK_SIZE = 1 << ( DocumentsWriter . INT_BLOCK_SHIFT ) ; static final int INT_BLOCK_MASK = ( DocumentsWriter . INT_BLOCK_SIZE ) - 1 ; private List < int [ ] > freeIntBlocks = new ArrayList < int [ ] > ( ) ; synchronized int [ ] getIntBlock ( ) { }

Fix:
message ( ( ( ( "flush:<seq2seq4repair_space>push<seq2seq4repair_space>buffered<seq2seq4repair_space>deletes<seq2seq4repair_space>startSize=" + ( pendingDeletes . bytesUsed . get ( ) ) ) + "<seq2seq4repair_space>frozenSize=" ) + ( packet . bytesUsed ) ) ) ;