Stig Rohde Døssing created KAFKA-17574:
------------------------------------------

             Summary: KafkaClusterTestKit produces error logs if shut down from 
a shutdown hook
                 Key: KAFKA-17574
                 URL: https://issues.apache.org/jira/browse/KAFKA-17574
             Project: Kafka
          Issue Type: Bug
            Reporter: Stig Rohde Døssing


I'd like to use KafkaClusterTestKit for running an embedded Kafka server in 
tests outside Kafka's own codebase. For most of my tests, I can reuse a single 
Kafka server, so I'd like to register a shutdown hook to terminate this 
instance.

I've noticed an unfortunate interaction with the way TestKitNodes chooses a 
base directory for the nodes: It uses 
[TestUtils.tempDirectory|https://github.com/apache/kafka/blob/74bebf6e3dfdc9de6894d656bdbbb28a4c33eda8/clients/src/test/java/org/apache/kafka/test/TestUtils.java#L262],
 which registers its own shutdown hook to remove the directory on JVM exit.

Since shutdown hooks run in arbitrary order, the tmp directory cleanup might 
run before the hook that terminates the KafkaClusterTestKit, which then causes 
noisy error logging.

I think it would be nice if KafkaClusterTestKit supported this use case. 
Allowing the user to specify a directory for the test cluster would allow the 
caller to choose not to use TestUtils.tempDirectory in a case like this.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to