mjsax commented on code in PR #19669:
URL: https://github.com/apache/kafka/pull/19669#discussion_r2083381191


##########
clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:
##########
@@ -2209,26 +2215,29 @@ public void 
testPartitionsForNonExistingTopic(GroupProtocol groupProtocol) {
     @ParameterizedTest
     @EnumSource(value = GroupProtocol.class, names = "CLASSIC")
     public void testPartitionsForAuthenticationFailure(GroupProtocol 
groupProtocol) {
-        final KafkaConsumer<String, String> consumer = 
consumerWithPendingAuthenticationError(groupProtocol);
-        assertThrows(AuthenticationException.class, () -> 
consumer.partitionsFor("some other topic"));
+        try (final KafkaConsumer<String, String> consumer = 
consumerWithPendingAuthenticationError(groupProtocol)) {
+            assertThrows(AuthenticationException.class, () -> 
consumer.partitionsFor("some other topic"));
+        }
     }
 
     // TODO: this test triggers a bug with the CONSUMER group protocol 
implementation.
     //       The bug will be investigated and fixed so this test can use both 
group protocols.
     @ParameterizedTest
     @EnumSource(value = GroupProtocol.class, names = "CLASSIC")
     public void testBeginningOffsetsAuthenticationFailure(GroupProtocol 
groupProtocol) {
-        final KafkaConsumer<String, String> consumer = 
consumerWithPendingAuthenticationError(groupProtocol);
-        assertThrows(AuthenticationException.class, () -> 
consumer.beginningOffsets(Collections.singleton(tp0)));
+        try (final KafkaConsumer<String, String> consumer = 
consumerWithPendingAuthenticationError(groupProtocol)) {
+            assertThrows(AuthenticationException.class, () -> 
consumer.beginningOffsets(Collections.singleton(tp0)));
+        }
     }
 
     // TODO: this test triggers a bug with the CONSUMER group protocol 
implementation.
     //       The bug will be investigated and fixed so this test can use both 
group protocols.
     @ParameterizedTest
     @EnumSource(value = GroupProtocol.class, names = "CLASSIC")
     public void testEndOffsetsAuthenticationFailure(GroupProtocol 
groupProtocol) {
-        final KafkaConsumer<String, String> consumer = 
consumerWithPendingAuthenticationError(groupProtocol);
-        assertThrows(AuthenticationException.class, () -> 
consumer.endOffsets(Collections.singleton(tp0)));
+        try (final KafkaConsumer<String, String> consumer = 
consumerWithPendingAuthenticationError(groupProtocol)) {
+            assertThrows(AuthenticationException.class, () -> 
consumer.endOffsets(Collections.singleton(tp0)));

Review Comment:
   Will be replaces with `Set.of(...)`



-- 
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

Reply via email to