hjtiun852 commented on code in PR #23277:
URL: https://github.com/apache/kafka/pull/23277#discussion_r3894971894


##########
clients/src/test/java/org/apache/kafka/clients/producer/ProducerRecordTest.java:
##########
@@ -53,26 +53,17 @@ public void testEqualsAndHashCode() {
 
     @Test
     public void testInvalidRecords() {
-        try {
-            new ProducerRecord<>(null, 0, "key", 1);
-            fail("Expected IllegalArgumentException to be raised because topic 
is null");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        assertThrows(IllegalArgumentException.class,
+                () -> new ProducerRecord<>(null, 0, "key", 1),
+                "Expected IllegalArgumentException to be raised because topic 
is null");

Review Comment:
   Thanks so much for the review! Removed.



##########
clients/src/test/java/org/apache/kafka/clients/producer/ProducerRecordTest.java:
##########
@@ -53,26 +53,17 @@ public void testEqualsAndHashCode() {
 
     @Test
     public void testInvalidRecords() {
-        try {
-            new ProducerRecord<>(null, 0, "key", 1);
-            fail("Expected IllegalArgumentException to be raised because topic 
is null");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        assertThrows(IllegalArgumentException.class,
+                () -> new ProducerRecord<>(null, 0, "key", 1),
+                "Expected IllegalArgumentException to be raised because topic 
is null");
 
-        try {
-            new ProducerRecord<>("test", 0, -1L, "key", 1);
-            fail("Expected IllegalArgumentException to be raised because of 
negative timestamp");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        assertThrows(IllegalArgumentException.class,
+                () -> new ProducerRecord<>("test", 0, -1L, "key", 1),
+                "Expected IllegalArgumentException to be raised because of 
negative timestamp");

Review Comment:
   ditto



##########
clients/src/test/java/org/apache/kafka/clients/producer/ProducerRecordTest.java:
##########
@@ -53,26 +53,17 @@ public void testEqualsAndHashCode() {
 
     @Test
     public void testInvalidRecords() {
-        try {
-            new ProducerRecord<>(null, 0, "key", 1);
-            fail("Expected IllegalArgumentException to be raised because topic 
is null");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        assertThrows(IllegalArgumentException.class,
+                () -> new ProducerRecord<>(null, 0, "key", 1),
+                "Expected IllegalArgumentException to be raised because topic 
is null");
 
-        try {
-            new ProducerRecord<>("test", 0, -1L, "key", 1);
-            fail("Expected IllegalArgumentException to be raised because of 
negative timestamp");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        assertThrows(IllegalArgumentException.class,
+                () -> new ProducerRecord<>("test", 0, -1L, "key", 1),
+                "Expected IllegalArgumentException to be raised because of 
negative timestamp");
 
-        try {
-            new ProducerRecord<>("test", -1, "key", 1);
-            fail("Expected IllegalArgumentException to be raised because of 
negative partition");
-        } catch (IllegalArgumentException e) {
-            //expected
-        }
+        assertThrows(IllegalArgumentException.class,
+                () -> new ProducerRecord<>("test", -1, "key", 1),
+                "Expected IllegalArgumentException to be raised because of 
negative partition");

Review Comment:
   ditto



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to