chiacyu commented on code in PR #16264:
URL: https://github.com/apache/kafka/pull/16264#discussion_r1636492176


##########
clients/src/test/java/org/apache/kafka/test/TestUtils.java:
##########
@@ -556,10 +558,22 @@ public static Set<TopicPartition> 
generateRandomTopicPartitions(int numTopic, in
      * @return The caught exception cause
      */
     public static <T extends Throwable> T assertFutureThrows(Future<?> future, 
Class<T> exceptionCauseClass) {
-        ExecutionException exception = assertThrows(ExecutionException.class, 
future::get);
-        assertInstanceOf(exceptionCauseClass, exception.getCause(),
-            "Unexpected exception cause " + exception.getCause());
-        return exceptionCauseClass.cast(exception.getCause());
+        try {
+            future.get(5, TimeUnit.SECONDS);
+            fail("expected to throw ExecutionException...");
+        } catch (TimeoutException e) {
+            fail("timeout waiting");
+            return null;
+        } catch (ExecutionException e) {
+            ExecutionException exception = 
assertThrows(ExecutionException.class, future::get);
+            assertInstanceOf(exceptionCauseClass, exception.getCause(),
+                    "Unexpected exception cause " + exception.getCause());
+            return exceptionCauseClass.cast(exception.getCause());
+        } catch (InterruptedException e) {
+            fail("Unexpected exception cause" + e.getCause());
+            return null;
+        }
+        return null;

Review Comment:
   Thanks for the comments here's some of my though:
   - The `fail()` will throw a `AssertionFailedError(message)`.
   - if there's no exception thrown, we should return assertion failed or null 
value to represent no exception thrown.
   WDYT?



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