divijvaidya commented on code in PR #12590:
URL: https://github.com/apache/kafka/pull/12590#discussion_r966819850


##########
clients/src/test/java/org/apache/kafka/common/security/authenticator/ClientAuthenticationFailureTest.java:
##########
@@ -90,12 +90,12 @@ public void testConsumerWithInvalidCredentials() {
         props.put(ConsumerConfig.GROUP_ID_CONFIG, "");
         StringDeserializer deserializer = new StringDeserializer();
 
-        try (KafkaConsumer<String, String> consumer = new 
KafkaConsumer<>(props, deserializer, deserializer)) {
-            assertThrows(SaslAuthenticationException.class, () -> {
-                consumer.subscribe(Collections.singleton(topic));
-                consumer.poll(Duration.ofSeconds(10));
-            });
-        }
+        KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props, 
deserializer, deserializer);
+        assertThrows(SaslAuthenticationException.class, () -> {
+            consumer.subscribe(Collections.singleton(topic));
+            consumer.poll(Duration.ofSeconds(10));
+            consumer.close();
+        });

Review Comment:
   This is because the `consumer.close()` tries to send a request to the server 
(the final fetch request introduced in this PR) which fails with authentication 
exception. Hence, a try-with-resource will fail throwing out an exception. 
Instead I have modified the code here to expect the authentication exception.



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