I'm trying to run some chronicle queue junit tests using the TempDir annotation, but the test fail because chronicle queue doesn't let go of the files before junit cleans up the temp dir, which causes the test to fail.
My temporary solution is to just Thread.sleep(1000) before the test ends, but I would rather not do that. It also only seems to be an issue on windows.
@TempDir
File temporaryDir;
@Test
public void testCQ() throws Exception {
ChronicleQueue cq = ChronicleQueue.singleBuilder(temporaryDir.getPath())
.wireType(WireType.BINARY_LIGHT)
.blockSize(128)
.bufferCapacity(128L)
.build();
try(final DocumentContext dc = cq.acquireAppender().writingDocument()) {
final Wire wire = dc.wire();
wire.write("test").text("test");
}
cq.close();
Thread.sleep(1000)
}
"java.io.IOException: Failed to delete temp directory. The following paths could not be deleted (see suppressed exceptions for details): , 20191106.cq4, metadata.cq4t"
"The process cannot access the file because it is being used by another process."
This is because we clean up resources in a separate thread. I wouldn't think it should take as long a s a second - I suggest you try doing a couple of Thread.yield()
s to hint cleanup thread that it's time to do some work.