[ 
https://issues.apache.org/jira/browse/KAFKA-19651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18127706#comment-18127706
 ] 

Shantanu commented on KAFKA-19651:
----------------------------------

The interrupt status is now restored where {{Thread.join()}} clears it, instead 
of at the {{close()}} rethrow.

https://github.com/apache/kafka/pull/23836

{{ConsumerNetworkThread.closeInternal}} catches {{InterruptedException}} from 
{{join()}} and calls {{Thread.currentThread().interrupt()}}. 
{{AsyncKafkaConsumer.close()}} still rethrows the saved {{InterruptException}} 
and does not set the flag itself. The classic consumer and the producer do not 
use this join, so they are unchanged.

This avoids the approach in the closed, unmerged PR #21864, which restored the 
flag only immediately before the rethrow. The new test starts a live network 
thread so {{join()}} actually waits, and checks that the interrupt status is 
still set after {{close()}}.

> Thread is not marked interrupted even when AsyncKafkaConsumer.close() throws 
> InterruptException
> -----------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-19651
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19651
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients, consumer
>    Affects Versions: 4.1.0
>            Reporter: Kirk True
>            Assignee: Shantanu
>            Priority: Major
>              Labels: consumer-threading-refactor
>
> There is a unit tests which perform these steps:
>  # Create consumer
>  # Interrupt thread
>  # Call Consumer.close()
>  # Check that InterruptException was thrown
>  # Call Thread.interrupted()
> In those cases, the return value from Thread.interrupted() is actually false. 
> We're catching the interrupted in the close() method but not restoring it 
> before we throw. This is inconsistent with the ClassicKafkaConsumer.



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

Reply via email to