Viliam Durina created KAFKA-6291:
------------------------------------

             Summary: Cannot close EmbeddedZookeeper on Windows
                 Key: KAFKA-6291
                 URL: https://issues.apache.org/jira/browse/KAFKA-6291
             Project: Kafka
          Issue Type: Bug
          Components: zkclient
    Affects Versions: 1.0.0, 0.11.0.0
         Environment: Windows 10 (doesn't reproduce on Linux)
JDK 8
            Reporter: Viliam Durina


We created {{EmbeddedZookeeper}} and {{ZkClient}} for various tests using this 
code:

{{
        EmbeddedZookeeper zkServer = new EmbeddedZookeeper();
        ZkClient zkClient = new ZkClient("127.0.0.1" + ':' + zkServer.port(), 
30000, 30000, ZKStringSerializer$.MODULE$);

        zkClient.close();
        zkServer.shutdown();
}}

This works fine on Linux, but on Windows, the {{zkServer.shutdown()}} call 
fails with this exception:

{{
[Thread-1] ERROR org.apache.kafka.test.TestUtils - Error deleting 
C:\Users\vilo\AppData\Local\Temp\kafka-5521621147877426083

java.nio.file.FileSystemException: 
C:\Users\vilo\AppData\Local\Temp\kafka-5521621147877426083\version-2\log.1: The 
process cannot access the file because it is being used by another process.

        at 
sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
        at 
sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
        at 
sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
        at 
sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
        at 
sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
        at java.nio.file.Files.delete(Files.java:1126)
        at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:630)
        at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:619)
        at java.nio.file.Files.walkFileTree(Files.java:2670)
        at java.nio.file.Files.walkFileTree(Files.java:2742)
        at org.apache.kafka.common.utils.Utils.delete(Utils.java:619)
        at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:184)

java.nio.file.FileSystemException: 
C:\Users\vilo\AppData\Local\Temp\kafka-5521621147877426083\version-2\log.1: The 
process cannot access the file because it is being used by another process.


        at 
sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
        at 
sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
        at 
sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
        at 
sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
        at 
sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
        at java.nio.file.Files.delete(Files.java:1126)
        at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:630)
        at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:619)
        at java.nio.file.Files.walkFileTree(Files.java:2670)
        at java.nio.file.Files.walkFileTree(Files.java:2742)
        at org.apache.kafka.common.utils.Utils.delete(Utils.java:619)
        at kafka.zk.EmbeddedZookeeper.shutdown(EmbeddedZookeeper.scala:53)
        at com.hazelcast.jet.KafkaTest.test(KafkaTest.java:32)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
        at 
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
        at 
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
        at 
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
}}

My workaround is to comment out the {{zkServer.shutdown()}} call, however this 
leaves GBs of files in temp directory.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to