为什么 Chronicle Queue 在关闭后会保留文件一秒钟?
Why does Chronicle Queue hold on to files for a second after close?
我正在尝试 运行 使用 TempDir 注释进行一些 chronicle queue junit 测试,但是测试失败了,因为 chronicle queue 在 junit 清理临时目录之前没有释放文件,这导致测试失败。
我的临时解决方案是在测试结束前 Thread.sleep(1000),但我宁愿不这样做。这似乎也只是 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."
这是因为我们在单独的线程中清理资源。我不认为它应该花费 s 秒那么长 - 我建议你尝试做几个 Thread.yield()
s 来提示清理线程是时候做一些工作了。
我正在尝试 运行 使用 TempDir 注释进行一些 chronicle queue junit 测试,但是测试失败了,因为 chronicle queue 在 junit 清理临时目录之前没有释放文件,这导致测试失败。
我的临时解决方案是在测试结束前 Thread.sleep(1000),但我宁愿不这样做。这似乎也只是 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."
这是因为我们在单独的线程中清理资源。我不认为它应该花费 s 秒那么长 - 我建议你尝试做几个 Thread.yield()
s 来提示清理线程是时候做一些工作了。