Buggy code:
private synchronized boolean optimizeMergesPending ( ) { } public void expungeDeletes ( boolean doWait ) throws IOException , CorruptIndexException { } public void expungeDeletes ( ) throws IOException , CorruptIndexException { } public final void maybeMerge ( ) throws IOException , CorruptIndexException { } private final void maybeMerge ( boolean optimize ) throws IOException , CorruptIndexException { } private final void maybeMerge ( int maxNumSegmentsOptimize , boolean optimize ) throws IOException , CorruptIndexException { } private synchronized void updatePendingMerges ( int maxNumSegmentsOptimize , boolean optimize ) throws IOException , CorruptIndexException { } synchronized OneMerge getNextMerge ( ) { } private synchronized OneMerge getNextExternalMerge ( ) { } private synchronized void startTransaction ( boolean haveReadLock ) throws IOException { } private synchronized void rollbackTransaction ( ) throws IOException { } private synchronized void commitTransaction ( ) throws IOException { } public void rollback ( ) throws IOException { } private void rollbackInternal ( ) throws IOException { } public synchronized void deleteAll ( ) throws IOException { } private synchronized void finishMerges ( boolean waitForMerges ) throws IOException { } public synchronized void waitForMerges ( ) { } private synchronized void checkpoint ( ) throws IOException { } private void finishAddIndexes ( ) { } private void blockAddIndexes ( ) { } private void resumeAddIndexes ( ) { } private synchronized void resetMergeExceptions ( ) { } private void noDupDirs ( Directory ... dirs ) { } public void addIndexesNoOptimize ( Directory ... dirs ) throws IOException , CorruptIndexException { } private boolean hasExternalSegments ( ) { } private void resolveExternalSegments ( ) throws IOException , CorruptIndexException { } public void addIndexes ( IndexReader ... readers ) throws IOException , CorruptIndexException { } protected void doAfterFlush ( ) throws IOException { } protected void doBeforeFlush ( ) throws IOException { } public final void prepareCommit ( ) throws IOException , CorruptIndexException { } public final void prepareCommit ( Map < String , String > commitUserData ) throws IOException , CorruptIndexException { } private final Object commitLock = new Object ( ) ; private void commit ( long sizeInBytes ) throws IOException { } public final void commit ( ) throws IOException , CorruptIndexException { } public final void commit ( Map < String , String > commitUserData ) throws IOException , CorruptIndexException { } private final synchronized void finishCommit ( ) throws IOException , CorruptIndexException { } protected final void flush ( boolean triggerMerge , boolean flushDocStores , boolean flushDeletes ) throws IOException , CorruptIndexException { } private final synchronized boolean doFlush ( boolean flushDocStores , boolean flushDeletes ) throws IOException , CorruptIndexException { } private final synchronized boolean doFlushInternal ( boolean flushDocStores , boolean flushDeletes ) throws IOException , CorruptIndexException { } public final long ramSizeInBytes ( ) { } public final synchronized int numRamDocs ( ) { } private int ensureContiguousMerge ( MergePolicy . OneMerge merge ) { } private synchronized void commitMergedDeletes ( MergePolicy . OneMerge merge , SegmentReader mergeReader ) throws IOException { } private synchronized boolean commitMerge ( MergePolicy . OneMerge merge , SegmentMerger merger , int mergedDocCount , SegmentReader mergedReader ) throws IOException { } private synchronized void decrefMergeSegments ( MergePolicy . OneMerge merge ) throws IOException { } private final void handleMergeException ( Throwable t , MergePolicy . OneMerge merge ) throws IOException { } final void merge ( MergePolicy . OneMerge merge ) throws IOException , CorruptIndexException { } void mergeSuccess ( MergePolicy . OneMerge merge ) { } final synchronized boolean registerMerge ( MergePolicy . OneMerge merge ) throws MergeAbortedException { } final synchronized void mergeInit ( MergePolicy . OneMerge merge ) throws IOException { } private final synchronized void _mergeInit ( MergePolicy . OneMerge merge ) throws IOException { } private void setDiagnostics ( SegmentInfo info , String source ) { } private void setDiagnostics ( SegmentInfo info , String source , Map < String , String > details ) { } final synchronized void mergeFinish ( MergePolicy . OneMerge merge ) throws IOException { } private final int mergeMiddle ( MergePolicy . OneMerge merge ) throws IOException , CorruptIndexException { } synchronized void addMergeException ( MergePolicy . OneMerge merge ) { } private final synchronized boolean applyDeletes ( ) throws IOException , CorruptIndexException { } final synchronized int getBufferedDeleteTermsSize ( ) { } final synchronized int getNumBufferedDeleteTerms ( ) { } SegmentInfo newestSegment ( ) { <START_BUG> return segmentInfos . info ( ( ( segmentInfos . size ( ) ) - 1 ) ) ; <END_BUG> } public synchronized String segString ( ) { } private synchronized String segString ( SegmentInfos infos ) { } private synchronized void doWait ( ) { } private void startCommit ( long sizeInBytes , Map < String , String > commitUserData ) throws IOException { } public static boolean isLocked ( Directory directory ) throws IOException { } public static void unlock ( Directory directory ) throws IOException { } public static final class MaxFieldLength { private int limit ; private String name ; private MaxFieldLength ( String name , int limit ) { } public MaxFieldLength ( int limit ) { } public int getLimit ( ) { } @ Override public String toString ( ) { } public static final IndexWriter . MaxFieldLength UNLIMITED = new IndexWriter . MaxFieldLength ( "UNLIMITED" , Integer . MAX_VALUE ) ; public static final IndexWriter . MaxFieldLength LIMITED = new IndexWriter . MaxFieldLength ( "LIMITED" , IndexWriter . DEFAULT_MAX_FIELD_LENGTH ) ; } public abstract static class IndexReaderWarmer { public abstract void warm ( IndexReader reader ) throws IOException { } } private IndexWriter . IndexReaderWarmer mergedSegmentWarmer ; public void setMergedSegmentWarmer ( IndexWriter . IndexReaderWarmer warmer ) { } public IndexWriter . IndexReaderWarmer getMergedSegmentWarmer ( ) { } private void handleOOM ( OutOfMemoryError oom , String location ) { } boolean testPoint ( String name ) { } synchronized boolean nrtIsCurrent ( SegmentInfos infos ) { } synchronized boolean isClosed ( ) { } public synchronized void deleteUnusedFiles ( ) throws IOException { } }

Fix:
return ( segmentInfos . size ( ) ) > 0 ? segmentInfos . info ( ( ( segmentInfos . size ( ) ) - 1 ) ) : null ;