Buggy code:
public class TestBufferedIndexInput extends LuceneTestCase { private static void writeBytes ( File aFile , long size ) throws IOException { } private static final long TEST_FILE_LENGTH = 100 * 1024 ; public void testReadByte ( ) throws Exception { } public void testReadBytes ( ) throws Exception { } private void runReadBytesAndClose ( IndexInput input , int bufferSize , Random r ) throws IOException { } private void runReadBytes ( IndexInput input , int bufferSize , Random r ) throws IOException { } private byte [ ] buffer = new byte [ 10 ] ; private void checkReadBytes ( IndexInput input , int size , int pos ) throws IOException { } public void testEOF ( ) throws Exception { } private static byte byten ( long n ) { } private static class MyBufferedIndexInput extends BufferedIndexInput { private long pos ; private long len ; public MyBufferedIndexInput ( long len ) { } public MyBufferedIndexInput ( ) { } @ Override protected void readInternal ( byte [ ] b , int offset , int length ) throws IOException { } @ Override protected void seekInternal ( long pos ) throws IOException { } @ Override public void close ( ) throws IOException { } @ Override public long length ( ) { } } public void testSetBufferSize ( ) throws IOException { <START_BUG> File indexDir = new File ( TEMP_DIR , "testSetBufferSize" ) ; <END_BUG> TestBufferedIndexInput . MockFSDirectory dir = new TestBufferedIndexInput . MockFSDirectory ( indexDir , random ) ; try { IndexWriter writer = new IndexWriter ( dir , new org . apache . lucene . index . IndexWriterConfig ( TEST_VERSION_CURRENT , new org . apache . lucene . analysis . WhitespaceAnalyzer ( TEST_VERSION_CURRENT ) ) . setOpenMode ( CREATE ) ) ; ( ( org . apache . lucene . index . LogMergePolicy ) ( writer . getConfig ( ) . getMergePolicy ( ) ) ) . setUseCompoundFile ( false ) ; for ( int i = 0 ; i < 37 ; i ++ ) { Document doc = new Document ( ) ; doc . add ( newField ( "content" , ( "aaa<seq2seq4repair_space>bbb<seq2seq4repair_space>ccc<seq2seq4repair_space>ddd" + i ) , YES , ANALYZED ) ) ; doc . add ( newField ( "id" , ( "" + i ) , YES , ANALYZED ) ) ; writer . addDocument ( doc ) ; } writer . close ( ) ; dir . allIndexInputs . clear ( ) ; IndexReader reader = IndexReader . open ( dir , false ) ; Term aaa = new Term ( "content" , "aaa" ) ; Term bbb = new Term ( "content" , "bbb" ) ; Term ccc = new Term ( "content" , "ccc" ) ; assertEquals ( 37 , reader . docFreq ( ccc ) ) ; reader . deleteDocument ( 0 ) ; assertEquals ( 37 , reader . docFreq ( aaa ) ) ; dir . tweakBufferSizes ( ) ; reader . deleteDocument ( 4 ) ; assertEquals ( reader . docFreq ( bbb ) , 37 ) ; dir . tweakBufferSizes ( ) ; IndexSearcher searcher = newSearcher ( reader ) ; ScoreDoc [ ] hits = searcher . search ( new org . apache . lucene . search . TermQuery ( bbb ) , null , 1000 ) . scoreDocs ; dir . tweakBufferSizes ( ) ; assertEquals ( 35 , hits . length ) ; dir . tweakBufferSizes ( ) ; hits = searcher . search ( new org . apache . lucene . search . TermQuery ( new Term ( "id" , "33" ) ) , null , 1000 ) . scoreDocs ; dir . tweakBufferSizes ( ) ; assertEquals ( 1 , hits . length ) ; hits = searcher . search ( new org . apache . lucene . search . TermQuery ( aaa ) , null , 1000 ) . scoreDocs ; dir . tweakBufferSizes ( ) ; assertEquals ( 35 , hits . length ) ; searcher . close ( ) ; reader . close ( ) ; } finally { _TestUtil . rmDir ( indexDir ) ; } } private static class MockFSDirectory extends Directory { List < IndexInput > allIndexInputs = new ArrayList < IndexInput > ( ) ; Random rand ; private Directory dir ; public MockFSDirectory ( File path , Random rand ) throws IOException { } @ Override public IndexInput openInput ( String name ) throws IOException { } public void tweakBufferSizes ( ) { } @ Override public IndexInput openInput ( String name , int bufferSize ) throws IOException { } @ Override public IndexOutput createOutput ( String name ) throws IOException { } @ Override public void close ( ) throws IOException { } @ Override public void deleteFile ( String name ) throws IOException { } @ Override public void touchFile ( String name ) throws IOException { } @ Override public long fileModified ( String name ) throws IOException { } @ Override public boolean fileExists ( String name ) throws IOException { } @ Override public String [ ] listAll ( ) throws IOException { } @ Override public long fileLength ( String name ) throws IOException { } } }

Fix:
File indexDir = _TestUtil . getTempDir ( "testSetBufferSize" ) ;