sunm2n opened a new pull request, #24240: URL: https://github.com/apache/kafka/pull/24240
KAFKA-21522: Clear the interrupt status before the global stream thread shuts down --- If `GlobalStreamThread` is interrupted while it is running, the interrupt surfaces as an `InterruptException`, whose constructor sets the interrupt status again. `run()` then calls the uncaught exception handler and closes the state consumer with the status still set, so the work the handler triggers (for example `addStreamThread` for `SHUTDOWN_APPLICATION`) runs on an interrupted thread and closing the global consumer can be cut short. Clear and record the status before the handler runs, clear it once more before the shutdown in the `finally` block, and restore it when the shutdown is complete, also when the shutdown throws. This is the same handling as in `StreamThread.run()` (KAFKA-21070). Two visible differences: the uncaught exception handler and the state listener now run with the status cleared, and the shutdown can take longer because the consumer close is no longer cut short. Not covered: an interrupt during `initialize()`. That path closes the state consumer with the status set as well, but it does not call the handler and returns before the run loop. New tests in `GlobalStreamThreadTest`: the status is cleared before the handler runs, cleared while the global consumer is closed and restored afterwards, cleared during the shutdown when the handler set it, and restored when the shutdown throws. The first three fail without the change; the last one fails if the restore is removed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
