lianetm commented on code in PR #16686:
URL: https://github.com/apache/kafka/pull/16686#discussion_r1757418153
##########
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:
Throwing this exception like this will bring a user-facing difference
between the 2 consumers on close if interrupted:
- classic consumer throws an InterruptException with InterruptedExpcetion as
cause (therefore message).
https://github.com/apache/kafka/blob/300e825be748e6aa55f86f6a6fa588398f1fcc73/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkClient.java#L537
- async consumer throws this different message
So should we throw the same just for consistency, and to avoid breaking
client apps that may expecting/checking for error messages?
--
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]