[GitHub] [kafka] showuon commented on a change in pull request #11864: KAFKA-13717: skip coordinator lookup in commitOffsetsAsync if offsets is empty
showuon commented on a change in pull request #11864: URL: https://github.com/apache/kafka/pull/11864#discussion_r823268006 ## File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java ## @@ -1000,8 +1000,11 @@ void invokeCompletedOffsetCommitCallbacks() { public RequestFuture commitOffsetsAsync(final Map offsets, final OffsetCommitCallback callback) { invokeCompletedOffsetCommitCallbacks(); -RequestFuture future = null; -if (!coordinatorUnknown()) { +RequestFuture 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: I checked again, and I think it's OK. Thanks. -- 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
[GitHub] [kafka] showuon commented on a change in pull request #11864: KAFKA-13717: skip coordinator lookup in commitOffsetsAsync if offsets is empty
showuon commented on a change in pull request #11864: URL: https://github.com/apache/kafka/pull/11864#discussion_r822634915 ## File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java ## @@ -1000,8 +1000,11 @@ void invokeCompletedOffsetCommitCallbacks() { public RequestFuture commitOffsetsAsync(final Map offsets, final OffsetCommitCallback callback) { invokeCompletedOffsetCommitCallbacks(); -RequestFuture future = null; -if (!coordinatorUnknown()) { +RequestFuture 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: I'm wonder if other dev would think this is a mistake when seeing this. Or at least we should leave a comment to mention this is on purpose. WDYT? -- 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
[GitHub] [kafka] showuon commented on a change in pull request #11864: KAFKA-13717: skip coordinator lookup in commitOffsetsAsync if offsets is empty
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 commitOffsetsAsync(final Map offsets, final OffsetCommitCallback callback) { invokeCompletedOffsetCommitCallbacks(); -RequestFuture future = null; -if (!coordinatorUnknown()) { +RequestFuture 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