Buggy code:
long sumDocFreq ; int docCount ; final FieldInfo info ; RAMField ( String field , FieldInfo info ) { } @ Override public long size ( ) { } @ Override public long getSumTotalTermFreq ( ) { } @ Override public long getSumDocFreq ( ) throws IOException { } @ Override public int getDocCount ( ) throws IOException { } @ Override public TermsEnum iterator ( TermsEnum reuse ) { } @ Override public Comparator < BytesRef > getComparator ( ) { } @ Override public boolean hasOffsets ( ) { } @ Override public boolean hasPositions ( ) { } @ Override public boolean hasPayloads ( ) { } } static class RAMTerm { final String term ; long totalTermFreq ; final List < RAMOnlyPostingsFormat . RAMDoc > docs = new ArrayList < RAMOnlyPostingsFormat . RAMDoc > ( ) ; public RAMTerm ( String term ) { } } static class RAMDoc { final int docID ; final int [ ] positions ; byte [ ] [ ] payloads ; public RAMDoc ( int docID , int freq ) { } } private static class RAMFieldsConsumer extends FieldsConsumer { private final RAMOnlyPostingsFormat . RAMPostings postings ; private final RAMOnlyPostingsFormat . RAMTermsConsumer termsConsumer = new RAMOnlyPostingsFormat . RAMTermsConsumer ( ) ; public RAMFieldsConsumer ( RAMOnlyPostingsFormat . RAMPostings postings ) { } @ Override public TermsConsumer addField ( FieldInfo field ) { } @ Override public void close ( ) { } } private static class RAMTermsConsumer extends TermsConsumer { private RAMOnlyPostingsFormat . RAMField field ; private final RAMOnlyPostingsFormat . RAMPostingsWriterImpl postingsWriter = new RAMOnlyPostingsFormat . RAMPostingsWriterImpl ( ) ; RAMOnlyPostingsFormat . RAMTerm current ; void reset ( RAMOnlyPostingsFormat . RAMField field ) { } @ Override public PostingsConsumer startTerm ( BytesRef text ) { } @ Override public Comparator < BytesRef > getComparator ( ) { } @ Override public void finishTerm ( BytesRef text , TermStats stats ) { } @ Override public void finish ( long sumTotalTermFreq , long sumDocFreq , int docCount ) { } } static class RAMPostingsWriterImpl extends PostingsConsumer { private RAMOnlyPostingsFormat . RAMTerm term ; private RAMOnlyPostingsFormat . RAMDoc current ; private int posUpto = 0 ; public void reset ( RAMOnlyPostingsFormat . RAMTerm term ) { } @ Override public void startDoc ( int docID , int freq ) { } @ Override public void addPosition ( int position , BytesRef payload , int startOffset , int endOffset ) { } @ Override public void finishDoc ( ) { } } static class RAMTermsEnum extends TermsEnum { Iterator < String > it ; String current ; private final RAMOnlyPostingsFormat . RAMField ramField ; public RAMTermsEnum ( RAMOnlyPostingsFormat . RAMField field ) { } @ Override public Comparator < BytesRef > getComparator ( ) { } @ Override public BytesRef next ( ) { } @ Override public SeekStatus seekCeil ( BytesRef term , boolean useCache ) { } @ Override public void seekExact ( long ord ) { } @ Override public long ord ( ) { } @ Override public BytesRef term ( ) { } @ Override public int docFreq ( ) { } @ Override public long totalTermFreq ( ) { } @ Override public DocsEnum docs ( Bits liveDocs , DocsEnum reuse , int flags ) { } @ Override public DocsAndPositionsEnum docsAndPositions ( Bits liveDocs , DocsAndPositionsEnum reuse , int flags ) { } } private static class RAMDocsEnum extends DocsEnum { private final RAMOnlyPostingsFormat . RAMTerm ramTerm ; private final Bits liveDocs ; private RAMOnlyPostingsFormat . RAMDoc current ; int upto = - 1 ; int posUpto = 0 ; public RAMDocsEnum ( RAMOnlyPostingsFormat . RAMTerm ramTerm , Bits liveDocs ) { } @ Override public int advance ( int targetDocID ) { } @ Override public int nextDoc ( ) { } @ Override public int freq ( ) throws IOException { } @ Override public int docID ( ) { } } private static class RAMDocsAndPositionsEnum extends DocsAndPositionsEnum { private final RAMOnlyPostingsFormat . RAMTerm ramTerm ; private final Bits liveDocs ; private RAMOnlyPostingsFormat . RAMDoc current ; int upto = - 1 ; int posUpto = 0 ; public RAMDocsAndPositionsEnum ( RAMOnlyPostingsFormat . RAMTerm ramTerm , Bits liveDocs ) { } @ Override public int advance ( int targetDocID ) { } @ Override public int nextDoc ( ) { } @ Override public int freq ( ) throws IOException { } @ Override public int docID ( ) { } @ Override public int nextPosition ( ) { } @ Override public int startOffset ( ) { } @ Override public int endOffset ( ) { } @ Override public BytesRef getPayload ( ) { } } private final Map < Integer , RAMOnlyPostingsFormat . RAMPostings > state = new HashMap < Integer , RAMOnlyPostingsFormat . RAMPostings > ( ) ; private final AtomicInteger nextID = new AtomicInteger ( ) ; private final String RAM_ONLY_NAME = "RAMOnly" ; private static final int VERSION_START = 0 ; private static final int VERSION_LATEST = RAMOnlyPostingsFormat . VERSION_START ; private static final String ID_EXTENSION = "id" ; @ Override public FieldsConsumer fieldsConsumer ( SegmentWriteState writeState ) throws IOException { } @ Override public FieldsProducer fieldsProducer ( SegmentReadState readState ) throws IOException { final String idFileName = IndexFileNames . segmentFileName ( readState . segmentInfo . name , readState . segmentSuffix , RAMOnlyPostingsFormat . ID_EXTENSION ) ; <START_BUG> IndexInput in = readState . dir . openInput ( idFileName , readState . context ) ; <END_BUG> boolean success = false ; final int id ; try { CodecUtil . checkHeader ( in , RAM_ONLY_NAME , RAMOnlyPostingsFormat . VERSION_START , RAMOnlyPostingsFormat . VERSION_LATEST ) ; id = in . readVInt ( ) ; success = true ; } finally { if ( ! success ) { IOUtils . closeWhileHandlingException ( in ) ; } else { IOUtils . close ( in ) ; } } synchronized ( state ) { return state . get ( id ) ; } } }

Fix:
IndexInput in = readState . directory . openInput ( idFileName , readState . context ) ;