Buggy code:
public class NIOFSDirectory extends FSDirectory { public NIOFSDirectory ( File path , LockFactory lockFactory ) throws IOException { } public NIOFSDirectory ( File path ) throws IOException { } @ Override public IndexInput openInput ( String name , int bufferSize ) throws IOException { } protected static class NIOFSIndexInput extends SimpleFSDirectory . SimpleFSIndexInput { private ByteBuffer byteBuf ; private byte [ ] otherBuffer ; private ByteBuffer otherByteBuf ; final FileChannel channel ; public NIOFSIndexInput ( File path , int bufferSize , int chunkSize ) throws IOException { } @ Override protected void newBuffer ( byte [ ] newBuffer ) { } @ Override public void close ( ) throws IOException { } @ Override protected void readInternal ( byte [ ] b , int offset , int len ) throws IOException { final ByteBuffer bb ; if ( ( b == ( buffer ) ) && ( 0 == offset ) ) { assert ( byteBuf ) != null ; byteBuf . clear ( ) ; byteBuf . limit ( len ) ; bb = byteBuf ; } else { if ( offset == 0 ) { if ( ( otherBuffer ) != b ) { otherBuffer = b ; otherByteBuf = ByteBuffer . wrap ( b ) ; } else otherByteBuf . clear ( ) ; otherByteBuf . limit ( len ) ; bb = otherByteBuf ; } else { bb = ByteBuffer . wrap ( b , offset , len ) ; } } int readOffset = bb . position ( ) ; int readLength = ( bb . limit ( ) ) - readOffset ; assert readLength == len ; long pos = getFilePointer ( ) ; try { while ( readLength > 0 ) { final int limit ; if ( readLength > ( chunkSize ) ) { limit = readOffset + ( chunkSize ) ; } else { limit = readOffset + readLength ; } bb . limit ( limit ) ; int i = channel . read ( bb , pos ) ; if ( i == ( - 1 ) ) { throw new IOException ( "read<seq2seq4repair_space>past<seq2seq4repair_space>EOF" ) ; } pos += i ; readOffset += i ; readLength -= i ; } } catch ( OutOfMemoryError e ) { <START_BUG> final OutOfMemoryError outOfMemoryError = new OutOfMemoryError ( ( ( ( "OutOfMemoryError<seq2seq4repair_space>likely<seq2seq4repair_space>caused<seq2seq4repair_space>by<seq2seq4repair_space>the<seq2seq4repair_space>Sun<seq2seq4repair_space>VM<seq2seq4repair_space>Bug<seq2seq4repair_space>described<seq2seq4repair_space>in<seq2seq4repair_space>" + ( "https:////issues.apache.org//jira//browse//LUCENE-1566;<seq2seq4repair_space>try<seq2seq4repair_space>calling<seq2seq4repair_space>FSDirectory.setReadChunkSize<seq2seq4repair_space>" + "with<seq2seq4repair_space>a<seq2seq4repair_space>a<seq2seq4repair_space>value<seq2seq4repair_space>smaller<seq2seq4repair_space>than<seq2seq4repair_space>the<seq2seq4repair_space>current<seq2seq4repair_space>chunk<seq2seq4repair_space>size<seq2seq4repair_space>(" ) ) + ( chunkSize ) ) + ")" ) ) ; <END_BUG> outOfMemoryError . initCause ( e ) ; throw outOfMemoryError ; } } } }

Fix:
final OutOfMemoryError outOfMemoryError = new OutOfMemoryError ( ( ( ( "OutOfMemoryError<seq2seq4repair_space>likely<seq2seq4repair_space>caused<seq2seq4repair_space>by<seq2seq4repair_space>the<seq2seq4repair_space>Sun<seq2seq4repair_space>VM<seq2seq4repair_space>Bug<seq2seq4repair_space>described<seq2seq4repair_space>in<seq2seq4repair_space>" + ( "https:////issues.apache.org//jira//browse//LUCENE-1566;<seq2seq4repair_space>try<seq2seq4repair_space>calling<seq2seq4repair_space>FSDirectory.setReadChunkSize<seq2seq4repair_space>" + "with<seq2seq4repair_space>a<seq2seq4repair_space>value<seq2seq4repair_space>smaller<seq2seq4repair_space>than<seq2seq4repair_space>the<seq2seq4repair_space>current<seq2seq4repair_space>chunk<seq2seq4repair_space>size<seq2seq4repair_space>(" ) ) + ( chunkSize ) ) + ")" ) ) ;