Copilot commented on code in PR #24240:
URL: https://github.com/apache/kafka/pull/24240#discussion_r4641671224
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java:
##########
@@ -278,6 +278,9 @@ long maxStoreUncommittedBytes() {
}
public void close(final boolean wipeStateStore) throws IOException {
+ // Clear the interrupt status before closing the consumer. With
the status set,
+ // the close gives up after one network poll and throws an
InterruptException.
+ Thread.interrupted();
try {
globalConsumer.close();
} catch (final RuntimeException e) {
Review Comment:
`Thread.interrupted()` clears the interrupt flag of *whichever thread calls*
`StateConsumer.close()`. Since `close(boolean)` is `public`, this can
unintentionally swallow an interrupt on a non-stream thread (e.g., a caller
performing shutdown/cleanup), breaking higher-level interrupt-based
cancellation semantics. Prefer moving the interrupt-clearing to the known
stream-thread-only call sites (e.g., right before invoking
`StateConsumer.close()` in `run()` and any initialization-failure path), or
alternatively capture the prior interrupt state, clear during
`globalConsumer.close()`, and then restore the interrupt flag for the calling
thread after the close attempt completes.
--
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]