Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
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)
- Getting error when running unit test HOT 5
- Add support for Kafka version 0.10.2.0 HOT 2
- java.lang.NoSuchFieldError: configFileStr HOT 3
- Does not work with dependency kafka-avro-serializer HOT 6
- JUnit 5 example test fails with NoSuchFieldError: configFileStr HOT 2
- Transactional producer not working HOT 2
- do not support transaction HOT 1
- Update to Kafka 2.1.1 HOT 2
- When using timeout to simulate "no-message" scenario, other regular test cases stop working HOT 4
- Kafka 2.3 is out HOT 2
- KafkaHelper threading issue HOT 3
- Kafka 2.4 HOT 3
- Multipartition topic HOT 2
- consumeStrings() discards buffered messages HOT 3
- Support Kafka 2.6
- kafka-junit support for kafka_2.13 (Kafka 2.6.0 recommends using Scala 2.13.x) HOT 3
- Breaking changes from Kafka 2.8.0 HOT 3
- EphemeralKafkaCluster with more than 2 brokers fails with NOT_ENOUGH_REPLICAS error HOT 1
- OWASP Dependency checker reported vulnerabilities in snappy java.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kafka-junit.