ShivsundarR commented on code in PR #18105:
URL: https://github.com/apache/kafka/pull/18105#discussion_r1877997069


##########
core/src/test/java/kafka/test/api/ShareConsumerTest.java:
##########
@@ -1919,29 +1798,27 @@ private <K, V> List<ConsumerRecord<K, V>> 
consumeRecords(KafkaShareConsumer<K, V
             ConsumerRecords<K, V> records = 
consumer.poll(Duration.ofMillis(100));
             records.forEach(accumulatedRecords::add);
             long currentTimeMs = System.currentTimeMillis();
-            if (currentTimeMs - startTimeMs > 60000) {
-                fail("Timed out before consuming expected records.");
-            }
+            assertFalse(currentTimeMs - startTimeMs > 60000, "Timed out before 
consuming expected records.");
         }
         return accumulatedRecords;
     }
 
     private void createTopic(String topicName) {
         Properties props = cluster.clientProperties();
-        try (Admin admin = Admin.create(props)) {
-            admin.createTopics(Collections.singleton(new NewTopic(topicName, 
1, (short) 1))).all().get();
-        } catch (Exception e) {
-            fail("Failed to create topic");
-        }
+        assertDoesNotThrow(() -> {
+            try (Admin admin = Admin.create(props)) {
+                admin.createTopics(Collections.singleton(new 
NewTopic(topicName, 1, (short) 1))).all().get();
+            }

Review Comment:
   Can we have the custom error message added here as well(`"Failed to create 
topic"`). Like in other parts of the code, we could maybe add that as the 
second argument for `assertDoesNotThrow`()?
   



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