showuon commented on a change in pull request #11864: URL: https://github.com/apache/kafka/pull/11864#discussion_r822620734
########## File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java ########## @@ -1000,8 +1000,11 @@ void invokeCompletedOffsetCommitCallbacks() { public RequestFuture<Void> commitOffsetsAsync(final Map<TopicPartition, OffsetAndMetadata> offsets, final OffsetCommitCallback callback) { invokeCompletedOffsetCommitCallbacks(); - RequestFuture<Void> future = null; - if (!coordinatorUnknown()) { + RequestFuture<Void> future = null; + if (offsets.isEmpty()) { + // No need to check coordinator if offsets is empty since commit of empty offsets is completed locally. + future = doCommitOffsetsAsync(offsets, callback); + } else if (!coordinatorUnknown()) { future = doCommitOffsetsAsync(offsets, callback); Review comment: Could we do this and add the comment above? ```java // No need to check coordinator if offsets is empty since commit of empty offsets is completed locally. if (offsets.isEmpty() || !coordinatorUnknown()) { future = doCommitOffsetsAsync(offsets, callback); } ``` ########## File path: core/src/test/scala/integration/kafka/api/AuthorizerIntegrationTest.scala ########## @@ -2483,6 +2483,20 @@ class AuthorizerIntegrationTest extends BaseRequestTest { } } + + @ParameterizedTest + @ValueSource(strings = Array("zk", "kraft")) + def testCreateAndCloseConsumerWithNoAccess(quorum: String): Unit = { + val consumer = createConsumer() + try { + // Close consumer without consuming anything. close() call should pass successfully and throw no exception. + consumer.close() + } catch { + case e: Throwable => + fail(s"Exception not expected on closing consumer: $e") + } Review comment: Could we use `assertDoesNotThrow` instead? I.e.: ```java assertDoesNotThrow(() => consumer.close(), s"Exception not expected on closing consumer) ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org