Program: 52239
Project: 52239
Buggy source:
@Test public void testDataFor() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000);
  final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 6);
  try {
    int cycle=(int)(System.currentTimeMillis() / 1000);
    VanillaMappedBytes vanillaBuffer0=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),0,true);
    vanillaBuffer0.writeLong(0,0x12345678);
    File file0=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),0,true);
    assertEquals(64 << 10,file0.length());
    assertEquals(0x12345678L,vanillaBuffer0.readLong(0));
    vanillaBuffer0.release();
    VanillaMappedBytes vanillaBuffer1=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),1,true);
    File file1=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),1,true);
    assertEquals(64 << 10,file1.length());
    vanillaBuffer1.release();
    assertNotEquals(file1,file0);
    VanillaMappedBytes vanillaBuffer2=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),2,true);
    File file2=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),2,true);
    assertEquals(64 << 10,file2.length());
    vanillaBuffer2.release();
    assertNotEquals(file2,file0);
    assertNotEquals(file2,file1);
    dataCache.close();
    assertEquals(0,vanillaBuffer0.refCount());
    assertEquals(0,vanillaBuffer1.refCount());
    assertEquals(0,vanillaBuffer2.refCount());
    assertTrue(file0.delete());
    assertTrue(file1.delete());
    assertTrue(file2.delete());
    assertTrue(file0.getParentFile().delete());
    dataCache.checkCounts(1,1);
  }
  finally {
    dataCache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}

Fixed version (ground truth):
@Test public void testDataFor() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000,GMT);
  final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 6);
  try {
    int cycle=(int)(System.currentTimeMillis() / 1000);
    VanillaMappedBytes vanillaBuffer0=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),0,true);
    vanillaBuffer0.writeLong(0,0x12345678);
    File file0=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),0,true);
    assertEquals(64 << 10,file0.length());
    assertEquals(0x12345678L,vanillaBuffer0.readLong(0));
    vanillaBuffer0.release();
    VanillaMappedBytes vanillaBuffer1=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),1,true);
    File file1=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),1,true);
    assertEquals(64 << 10,file1.length());
    vanillaBuffer1.release();
    assertNotEquals(file1,file0);
    VanillaMappedBytes vanillaBuffer2=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),2,true);
    File file2=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),2,true);
    assertEquals(64 << 10,file2.length());
    vanillaBuffer2.release();
    assertNotEquals(file2,file0);
    assertNotEquals(file2,file1);
    dataCache.close();
    assertEquals(0,vanillaBuffer0.refCount());
    assertEquals(0,vanillaBuffer1.refCount());
    assertEquals(0,vanillaBuffer2.refCount());
    assertTrue(file0.delete());
    assertTrue(file1.delete());
    assertTrue(file2.delete());
    assertTrue(file0.getParentFile().delete());
    dataCache.checkCounts(1,1);
  }
  finally {
    dataCache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}