Buggy code:
private LogMergePolicy getLogMergePolicy ( ) { } @ Deprecated public boolean getUseCompoundFile ( ) { } @ Deprecated public void setUseCompoundFile ( boolean value ) { } @ Deprecated public void setSimilarity ( Similarity similarity ) { } @ Deprecated public Similarity getSimilarity ( ) { } @ Deprecated public void setTermIndexInterval ( int interval ) { } @ Deprecated public int getTermIndexInterval ( ) { } @ Deprecated public IndexWriter ( Directory d , Analyzer a , boolean create , IndexWriter . MaxFieldLength mfl ) throws IOException , CorruptIndexException , LockObtainFailedException { } @ Deprecated public IndexWriter ( Directory d , Analyzer a , IndexWriter . MaxFieldLength mfl ) throws IOException , CorruptIndexException , LockObtainFailedException { } @ Deprecated public IndexWriter ( Directory d , Analyzer a , IndexDeletionPolicy deletionPolicy , IndexWriter . MaxFieldLength mfl ) throws IOException , CorruptIndexException , LockObtainFailedException { } @ Deprecated public IndexWriter ( Directory d , Analyzer a , boolean create , IndexDeletionPolicy deletionPolicy , IndexWriter . MaxFieldLength mfl ) throws IOException , CorruptIndexException , LockObtainFailedException { } @ Deprecated public IndexWriter ( Directory d , Analyzer a , IndexDeletionPolicy deletionPolicy , IndexWriter . MaxFieldLength mfl , IndexCommit commit ) throws IOException , CorruptIndexException , LockObtainFailedException { } public IndexWriter ( Directory d , IndexWriterConfig conf ) throws IOException , CorruptIndexException , LockObtainFailedException { } private FieldInfos getCurrentFieldInfos ( ) throws IOException { } private synchronized void setRollbackSegmentInfos ( SegmentInfos infos ) { } public IndexWriterConfig getConfig ( ) { } @ Deprecated public void setMergePolicy ( MergePolicy mp ) { } @ Deprecated public MergePolicy getMergePolicy ( ) { } @ Deprecated public synchronized void setMergeScheduler ( MergeScheduler mergeScheduler ) throws IOException , CorruptIndexException { } @ Deprecated public MergeScheduler getMergeScheduler ( ) { } @ Deprecated public void setMaxMergeDocs ( int maxMergeDocs ) { } @ Deprecated public int getMaxMergeDocs ( ) { } @ Deprecated public void setMaxFieldLength ( int maxFieldLength ) { } @ Deprecated public int getMaxFieldLength ( ) { } @ Deprecated public void setReaderTermsIndexDivisor ( int divisor ) { } @ Deprecated public int getReaderTermsIndexDivisor ( ) { } @ Deprecated public void setMaxBufferedDocs ( int maxBufferedDocs ) { } private void pushMaxBufferedDocs ( ) { } @ Deprecated public int getMaxBufferedDocs ( ) { } @ Deprecated public void setRAMBufferSizeMB ( double mb ) { } @ Deprecated public double getRAMBufferSizeMB ( ) { } @ Deprecated public void setMaxBufferedDeleteTerms ( int maxBufferedDeleteTerms ) { } @ Deprecated public int getMaxBufferedDeleteTerms ( ) { } @ Deprecated public void setMergeFactor ( int mergeFactor ) { } @ Deprecated public int getMergeFactor ( ) { } public static void setDefaultInfoStream ( PrintStream infoStream ) { } public static PrintStream getDefaultInfoStream ( ) { } public void setInfoStream ( PrintStream infoStream ) { } private void messageState ( ) { } public PrintStream getInfoStream ( ) { } public boolean verbose ( ) { } @ Deprecated public void setWriteLockTimeout ( long writeLockTimeout ) { } @ Deprecated public long getWriteLockTimeout ( ) { } @ Deprecated public static void setDefaultWriteLockTimeout ( long writeLockTimeout ) { } @ Deprecated public static long getDefaultWriteLockTimeout ( ) { } public void close ( ) throws IOException , CorruptIndexException { } public void close ( boolean waitForMerges ) throws IOException , CorruptIndexException { } private synchronized boolean shouldClose ( ) { } private void closeInternal ( boolean waitForMerges ) throws IOException , CorruptIndexException { } private synchronized boolean flushDocStores ( ) throws IOException { } public Directory getDirectory ( ) { } public Analyzer getAnalyzer ( ) { } public synchronized int maxDoc ( ) { } public synchronized int numDocs ( ) throws IOException { int count ; if ( ( docWriter ) != null ) count = docWriter . getNumDocsInRAM ( ) ; else count = 0 ; for ( int i = 0 ; i < ( segmentInfos . size ( ) ) ; i ++ ) { final SegmentInfo info = segmentInfos . info ( i ) ; <START_BUG> count += ( info . docCount ) - ( info . getDelCount ( ) ) ; <END_BUG> } return count ; } public synchronized boolean hasDeletions ( ) throws IOException { } private int maxFieldLength ; public void addDocument ( Document doc ) throws IOException , CorruptIndexException { } public void addDocument ( Document doc , Analyzer analyzer ) throws IOException , CorruptIndexException { } public void deleteDocuments ( Term term ) throws IOException , CorruptIndexException { } public void deleteDocuments ( Term ... terms ) throws IOException , CorruptIndexException { } public void deleteDocuments ( Query query ) throws IOException , CorruptIndexException { } public void deleteDocuments ( Query ... queries ) throws IOException , CorruptIndexException { } public void updateDocument ( Term term , Document doc ) throws IOException , CorruptIndexException { } public void updateDocument ( Term term , Document doc , Analyzer analyzer ) throws IOException , CorruptIndexException { } final synchronized int getSegmentCount ( ) { } final synchronized int getNumBufferedDocuments ( ) { } final synchronized int getDocCount ( int i ) { } final synchronized int getFlushCount ( ) { } final synchronized int getFlushDeletesCount ( ) { } final String newSegmentName ( ) { } private PrintStream infoStream = null ; private static PrintStream defaultInfoStream = null ; public void optimize ( ) throws IOException , CorruptIndexException { } public void optimize ( int maxNumSegments ) throws IOException , CorruptIndexException { } public void optimize ( boolean doWait ) throws IOException , CorruptIndexException { } public void optimize ( int maxNumSegments , boolean doWait ) throws IOException , CorruptIndexException { } 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 { }

Fix:
count += ( info . docCount ) - ( numDeletedDocs ( info ) ) ;