'AccessDeniedException for Kafka 3 default state.dir

The following error would appear every 5 seconds when we have Kafka running on Windows 10.

Failed to write offset checkpoint file to C:/tmp/kafka-streams/user/global/.checkpoint for global stores: {}. This may occur if OS cleaned the state.dir in case when it is located in the (default) ${java.io.tmpdir}/kafka-streams directory. Changing the location of state.dir may resolve the problem.

java.nio.file.AccessDeniedException: C:/tmp/kafka-streams/user/global

Here is our Gradle. At the time of writing, this will import the 3.0 version by default.

api 'org.apache.kafka:kafka-streams'
api 'org.apache.kafka:kafka-clients'

I have checked the folder permissions and it seems be to read-only for the kafka-streams subfolders. Even if I change that, it'd go back to read-only.

Environment

JDK 17.0.2
Kafka 3.0
Windows 10


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source