lianetm commented on code in PR #15640: URL: https://github.com/apache/kafka/pull/15640#discussion_r1608418633
########## clients/src/test/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumerTest.java: ########## @@ -329,6 +334,17 @@ public void testCommitAsyncWithFencedException() { commitEvent.future().completeExceptionally(Errors.FENCED_INSTANCE_ID.exception()); assertThrows(Errors.FENCED_INSTANCE_ID.exception().getClass(), () -> consumer.commitAsync()); + + // Close the consumer here as we know it will cause a FencedInstanceIdException to be thrown. + // If we get an error other than the FencedInstanceIdException, we'll raise a ruckus. + try { + consumer.close(); + } catch (KafkaException e) { + assertNotNull(e.getCause()); + assertInstanceOf(FencedInstanceIdException.class, e.getCause()); + } finally { + consumer = null; + } Review Comment: Do we expect the close to throw? If so, we should verify that (at the moment our test will just complete successfully if the close does not throw). If that's the expectation, maybe this simpler snippet would cover it all: ```suggestion Throwable e = assertThrows(KafkaException.class, () -> consumer.close()); assertInstanceOf(FencedInstanceIdException.class, e.getCause()); consumer = null; ``` -- 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