Giter VIP home page Giter VIP logo

Comments (9)

charithe avatar charithe commented on June 4, 2024

Thanks for reporting the issue. Unfortunately I can't provide support for the Windows platform. If you know how to fix the problem, please send a PR and I'll be happy to accept it.

from kafka-junit.

mariankassovic avatar mariankassovic commented on June 4, 2024

I have only a small improvement - add awaitShutdown() call in EphemeralKafkaBroker method stopBroker before trying to delete Kafka log directory.

  private void stopBroker() {
        try {
            if (kafkaServer != null) {
                LOGGER.info("Shutting down Kafka Server");
                kafkaServer.shutdown();
                kafkaServer.awaitShutdown();
            }

Unfortunately it does not solve the problem completely, since it looks like Kafka does not close topic properly on shutdown :-( Tests run green, but temp folder clean-up is failing...

from kafka-junit.

charithe avatar charithe commented on June 4, 2024

Yes, I remember reading that Windows creates exclusive locks on files whereas Unix-like systems don't. This is probably something to do with that. I'll mark this as up-for-grabs so that someone with knowledge of Windows (and access to a Windows machine) can pick it up and work on it.

from kafka-junit.

eximius313 avatar eximius313 commented on June 4, 2024

I'm also suffering from this:

2018-03-22 13:36:28.080 ERROR 5828 --- [       Thread-8] org.apache.kafka.test.TestUtils          : Error deleting C:\Users\X\AppData\Local\Temp\kafka-5223924343707963804

java.nio.file.FileSystemException: C:\Users\X\AppData\Local\Temp\kafka-5223924343707963804\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) ~[na:1.8.0_144]
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[na:1.8.0_144]
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[na:1.8.0_144]
	at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) ~[na:1.8.0_144]
	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) ~[na:1.8.0_144]
	at java.nio.file.Files.delete(Files.java:1126) ~[na:1.8.0_144]
	at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:630) ~[kafka-clients-1.0.1.jar:na]
	at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
	at java.nio.file.Files.walkFileTree(Files.java:2670) ~[na:1.8.0_144]
	at java.nio.file.Files.walkFileTree(Files.java:2742) ~[na:1.8.0_144]
	at org.apache.kafka.common.utils.Utils.delete(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
	at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:184) ~[kafka-clients-1.0.1-test.jar:na]

2018-03-22 13:36:28.091 ERROR 5828 --- [      Thread-11] org.apache.kafka.test.TestUtils          : Error deleting C:\Users\X\AppData\Local\Temp\kafka-5049848438722543295

java.nio.file.FileSystemException: C:\Users\X\AppData\Local\Temp\kafka-5049848438722543295\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) ~[na:1.8.0_144]
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[na:1.8.0_144]
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[na:1.8.0_144]
	at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) ~[na:1.8.0_144]
	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) ~[na:1.8.0_144]
	at java.nio.file.Files.delete(Files.java:1126) ~[na:1.8.0_144]
	at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:630) ~[kafka-clients-1.0.1.jar:na]
	at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
	at java.nio.file.Files.walkFileTree(Files.java:2670) ~[na:1.8.0_144]
	at java.nio.file.Files.walkFileTree(Files.java:2742) ~[na:1.8.0_144]
	at org.apache.kafka.common.utils.Utils.delete(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
	at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:184) ~[kafka-clients-1.0.1-test.jar:na]

from kafka-junit.

carlislefox avatar carlislefox commented on June 4, 2024

Also experiencing this issue

2018-04-03 15:56:25.652 ERROR 4816 --- [ Thread-4] org.apache.kafka.test.TestUtils : Error deleting C:\Users\stewalia\AppData\Local\Temp\kafka-7101259950782722212

java.nio.file.FileSystemException: C:\Users\stewalia\AppData\Local\Temp\kafka-7101259950782722212\product-0\00000000000000000000.index: 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$2.visitFile(Utils.java:591)
    at org.apache.kafka.common.utils.Utils$2.visitFile(Utils.java:580)
    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:580)
    at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:182)

from kafka-junit.

cyriljoui avatar cyriljoui commented on June 4, 2024

Hi

We were facing the same issue.
However it is a no blocking issue (in our case), the real issue may when we use Helper.produceStrings

in this.produce() ... it should be better to call .get() to be sure that message was really produced (sync)

public <K, V> void produce(String topic, KafkaProducer<K, V> producer, Map<K, V> data) {
    data.forEach((k, v) -> {
        producer.send(new ProducerRecord(topic, k, v));
    });
    producer.flush();
}
    protected <K, V> void produce(String topic, KafkaProducer<K, V> producer, Map<K, V> data) {
        data.forEach((k, v) -> {
            try {
                producer.send(new ProducerRecord(topic, k, v)).get();
            } catch (InterruptedException e) {
               throw new RuntimeException(e);
            } catch (ExecutionException e) {
                throw new RuntimeException(e);
            }
        });
        producer.flush();
    }

Could you please give more details about how do you implement your tests? which methods, classes do you use to consume / produce messages?

from kafka-junit.

silaev avatar silaev commented on June 4, 2024

faced the same issue, as a workaround added the following to a Gradle clean task:

import org.apache.tools.ant.taskdefs.condition.Os

clean {
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        def tempDir = System.getProperties().getProperty("java.io.tmpdir")
        def ft = fileTree(tempDir) {
            include 'kafka-*'
            exclude 'kafka-logs'
        }
        ft.visit {
            FileVisitDetails fvd ->
                println "deleted kafka temp folder: " + tempDir + fvd.name
                delete fvd.file
        }
    }
} 

from kafka-junit.

mjiderhamn avatar mjiderhamn commented on June 4, 2024

This problem prevents me from upgrading as well. My error message is slightly different however

ERROR kafka.server.BrokerMetadataCheckpoint - Failed to write meta.properties due to
java.nio.file.AccessDeniedException: C:\Users\Maji\AppData\Local\Temp\kafka_junit16787608145441309316

from kafka-junit.

mjiderhamn avatar mjiderhamn commented on June 4, 2024

At least in my case, the issue seems to be with Kafka itself https://issues.apache.org/jira/browse/KAFKA-13390 = apache/kafka#11426

from kafka-junit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.