4

I am using spring kafka with the embedded kafka for JUnit test, it gives an error for every test on windows:

Error deleting C:\Users:LXX691\AppData\Local\Temp\kafka-1103610162480947200/.lock: The process cannot access the file because it is being used by another process.

I just did the basic configuration like below

@SpringBootTest(webEnvironment = RANDOM_PORT)
@RunWith(SpringRunner.class)
public class KafkaTest {
  @Autowired
  EmbeddedKafkaBroker broker;

  @Before
  void setUp() throws Exception() {
    // setup producer and consumers
  }

  @Test
  void test() {
    producer.send(new ProducerRecord<>("topic", "content"));
  }
}

Any suggestion to resolve or any workaround is appreciated.

Jakim
  • 1,713
  • 7
  • 20
  • 44

1 Answers1

2

This is a known issue in Apache Kafka: https://issues.apache.org/jira/browse/KAFKA-8145.

Unfortunately there is nothing in Spring Kafka we can do on the matter.

See more info here: Kafka: unable to start Kafka - process can not access file 00000000000000000000.timeindex and here https://github.com/spring-projects/spring-kafka/issues/194

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118