mimaison commented on code in PR #15877:
URL: https://github.com/apache/kafka/pull/15877#discussion_r1598589821


##########
clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:
##########
@@ -2288,23 +2253,15 @@ public void testRebalanceException(GroupProtocol 
groupProtocol) {
         client.prepareResponseFrom(syncGroupResponse(singletonList(tp0), 
Errors.NONE), coordinator);
 
         // assign throws
-        try {
-            
consumer.updateAssignmentMetadataIfNeeded(time.timer(Long.MAX_VALUE));
-            fail("Should throw exception");
-        } catch (Throwable e) {
-            assertEquals(partitionAssigned + singleTopicPartition, 
e.getCause().getMessage());
-        }
+        Throwable t = assertThrows(Throwable.class, () -> 
consumer.updateAssignmentMetadataIfNeeded(time.timer(Long.MAX_VALUE)));
+        assertEquals(partitionAssigned + singleTopicPartition, 
t.getCause().getMessage());
 
         // the assignment is still updated regardless of the exception
         assertEquals(singleton(tp0), subscription.assignedPartitions());
 
         // close's revoke throws
-        try {
-            consumer.close(Duration.ofMillis(0));
-            fail("Should throw exception");
-        } catch (Throwable e) {
-            assertEquals(partitionRevoked + singleTopicPartition, 
e.getCause().getCause().getMessage());
-        }
+        t = assertThrows(Throwable.class, () -> 
consumer.close(Duration.ofMillis(0)));

Review Comment:
   Good call, I pushed an update.
   Thanks for raising KAFKA-16737



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