Hi Kafka Dev/Users,

While running tests in `StreamThreadTest.java` in kafka/streams, I noticed
the test left many lingering threads. Though the class runs `shutdown`
after each test, the shutdown only executes `completeShutdown` if the
StreamThread is in CREATED state. See
https://github.com/apache/kafka/blob/0b11971f2c94f7aadc3fab2c51d94642065a72e5/streams/src/test/java/org/apache/kafka/streams/processor/internals/StreamThreadTest.java#L231
and
https://github.com/apache/kafka/blob/0b11971f2c94f7aadc3fab2c51d94642065a72e5/streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java#L1435

For example, you may run
test 
org.apache.kafka.streams.processor.internals.StreamThreadTest#shouldNotCloseTaskProducerWhenSuspending
with commit 0b11971f2c94f7aadc3fab2c51d94642065a72e5. When the test calls
`thread.shutdown()`, the thread is in `PARTITIONS_REVOKED` state. Thus,
`completeShutdown` is not called. The test creates three lingering threads:
2 `StateUpdater` and 1 `TaskExecutor`

Is this expected behavior? Should StreamTread call `completeShutdown` in
other states?

Thanks,
Ao

Reply via email to