Buggy code:
private HashtableOfObject categoryTables ; private char [ ] cachedCategoryName ; public static final String SIGNATURE = "INDEX<seq2seq4repair_space>VERSION<seq2seq4repair_space>1.106" ; public static boolean DEBUG = false ; private static final int RE_INDEXED = - 1 ; private static final int DELETED = - 2 ; private static final int CHUNK_SIZE = 100 ; class IntList { int size ; int [ ] elements ; IntList ( int [ ] elements ) { } void add ( int newElement ) { } int [ ] asArray ( ) { } } DiskIndex ( String fileName ) { } SimpleSet addDocumentNames ( String substring , MemoryIndex memoryIndex ) throws IOException { } private HashtableOfObject addQueryResult ( HashtableOfObject results , char [ ] word , HashtableOfObject wordsToDocNumbers , MemoryIndex memoryIndex ) throws IOException { } HashtableOfObject addQueryResults ( char [ ] [ ] categories , char [ ] key , int matchRule , MemoryIndex memoryIndex ) throws IOException { } private void cacheDocumentNames ( ) throws IOException { } private String [ ] computeDocumentNames ( String [ ] onDiskNames , int [ ] positions , SimpleLookupTable indexedDocuments , MemoryIndex memoryIndex ) { } private void copyQueryResults ( HashtableOfObject categoryToWords , int newPosition ) { } File getIndexFile ( ) { } void initialize ( boolean reuseExistingFile ) throws IOException { } private void initializeFrom ( DiskIndex diskIndex , File newIndexFile ) throws IOException { } private void mergeCategories ( DiskIndex onDisk , int [ ] positions , DataOutputStream stream ) throws IOException { } private void mergeCategory ( char [ ] categoryName , DiskIndex onDisk , int [ ] positions , DataOutputStream stream ) throws IOException { } DiskIndex mergeWith ( MemoryIndex memoryIndex ) throws IOException { String [ ] docNames = readAllDocumentNames ( ) ; int previousLength = docNames . length ; int [ ] positions = new int [ previousLength ] ; SimpleLookupTable indexedDocuments = new SimpleLookupTable ( 3 ) ; docNames = computeDocumentNames ( docNames , positions , indexedDocuments , memoryIndex ) ; if ( ( docNames . length ) == 0 ) { if ( previousLength == 0 ) return this ; DiskIndex newDiskIndex = new DiskIndex ( this . fileName ) ; newDiskIndex . initialize ( false ) ; return newDiskIndex ; } DiskIndex newDiskIndex = new DiskIndex ( ( ( this . fileName ) + ".tmp" ) ) ; File newIndexFile = newDiskIndex . getIndexFile ( ) ; try { newDiskIndex . initializeFrom ( this , newIndexFile ) ; DataOutputStream stream = new DataOutputStream ( new BufferedOutputStream ( new FileOutputStream ( newIndexFile , false ) , 2048 ) ) ; int offsetToHeader = - 1 ; try { newDiskIndex . writeAllDocumentNames ( docNames , stream ) ; docNames = null ; if ( ( indexedDocuments . elementSize ) > 0 ) { Object [ ] names = indexedDocuments . keyTable ; Object [ ] integerPositions = indexedDocuments . valueTable ; for ( int i = 0 , l = names . length ; i < l ; i ++ ) if ( ( names [ i ] ) != null ) newDiskIndex . copyQueryResults ( ( ( HashtableOfObject ) ( memoryIndex . docsToReferences . get ( names [ i ] ) ) ) , ( ( Integer ) ( integerPositions [ i ] ) ) . intValue ( ) ) ; } indexedDocuments = null ; if ( previousLength == 0 ) newDiskIndex . writeCategories ( stream ) ; else newDiskIndex . mergeCategories ( this , positions , stream ) ; offsetToHeader = stream . size ( ) ; newDiskIndex . writeHeaderInfo ( stream ) ; positions = null ; } finally { stream . close ( ) ; } newDiskIndex . writeOffsetToHeader ( offsetToHeader ) ; File old = getIndexFile ( ) ; <START_BUG> if ( ! ( old . delete ( ) ) ) { <END_BUG> if ( DiskIndex . DEBUG ) System . out . println ( ( "mergeWith<seq2seq4repair_space>-<seq2seq4repair_space>Failed<seq2seq4repair_space>to<seq2seq4repair_space>delete<seq2seq4repair_space>" + ( this . fileName ) ) ) ; throw new IOException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>delete<seq2seq4repair_space>index<seq2seq4repair_space>file<seq2seq4repair_space>" + ( this . fileName ) ) ) ; } if ( ! ( newIndexFile . renameTo ( old ) ) ) { if ( DiskIndex . DEBUG ) System . out . println ( ( "mergeWith<seq2seq4repair_space>-<seq2seq4repair_space>Failed<seq2seq4repair_space>to<seq2seq4repair_space>rename<seq2seq4repair_space>" + ( this . fileName ) ) ) ; throw new IOException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>rename<seq2seq4repair_space>index<seq2seq4repair_space>file<seq2seq4repair_space>" + ( this . fileName ) ) ) ; } } catch ( IOException e ) { if ( ( newIndexFile . exists ( ) ) && ( ! ( newIndexFile . delete ( ) ) ) ) if ( DiskIndex . DEBUG ) System . out . println ( ( "mergeWith<seq2seq4repair_space>-<seq2seq4repair_space>Failed<seq2seq4repair_space>to<seq2seq4repair_space>delete<seq2seq4repair_space>temp<seq2seq4repair_space>index<seq2seq4repair_space>" + ( newDiskIndex . fileName ) ) ) ; throw e ; } newDiskIndex . fileName = this . fileName ; return newDiskIndex ; } private synchronized String [ ] readAllDocumentNames ( ) throws IOException { } private synchronized HashtableOfObject readCategoryTable ( char [ ] categoryName , boolean readDocNumbers ) throws IOException { } private void readChunk ( String [ ] docNames , DataInputStream stream , int index , int size ) throws IOException { } private int [ ] readDocumentArray ( DataInputStream stream , int arraySize ) throws IOException { } synchronized String readDocumentName ( int docNumber ) throws IOException { } synchronized int [ ] readDocumentNumbers ( Object arrayOffset ) throws IOException { } private void readHeaderInfo ( RandomAccessFile file ) throws IOException { } synchronized void startQuery ( ) { } synchronized void stopQuery ( ) { } private void writeAllDocumentNames ( String [ ] sortedDocNames , DataOutputStream stream ) throws IOException { } private void writeCategories ( DataOutputStream stream ) throws IOException { } private void writeCategoryTable ( char [ ] categoryName , HashtableOfObject wordsToDocs , DataOutputStream stream ) throws IOException { } private void writeDocumentNumbers ( int [ ] documentNumbers , DataOutputStream stream ) throws IOException { } private void writeHeaderInfo ( DataOutputStream stream ) throws IOException { } private void writeOffsetToHeader ( int offsetToHeader ) throws IOException { } }

Fix:
if ( ( old . exists ( ) ) && ( ! ( old . delete ( ) ) ) ) {