kirktrue commented on code in PR #16686:
URL: https://github.com/apache/kafka/pull/16686#discussion_r1775818145
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:
##########
@@ -1258,9 +1259,11 @@ private void close(Duration timeout, boolean
swallowException) {
AppInfoParser.unregisterAppInfo(CONSUMER_JMX_PREFIX, clientId,
metrics);
log.debug("Kafka consumer has been closed");
Throwable exception = firstException.get();
- if (exception != null && !swallowException) {
+ if ((wasInterrupted || exception != null) && !swallowException) {
if (exception instanceof InterruptException) {
throw (InterruptException) exception;
+ } else if (wasInterrupted) {
+ throw new InterruptException("Consumer was interrupted by user
prior to close()");
Review Comment:
I changed the `AsyncKafkaConsumer` to use the same approach for exception
throwing. I also augmented the unit tests to check for a nested
`InterruptedException`.
--
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]