peterxcli commented on code in PR #18296:
URL: https://github.com/apache/kafka/pull/18296#discussion_r1898777862


##########
clients/src/test/java/org/apache/kafka/test/TestUtils.java:
##########
@@ -583,19 +583,6 @@ public static <T extends Throwable> void 
assertFutureThrows(
         assertEquals(expectedMessage, receivedException.getMessage());
     }
 
-    public static void assertFutureError(Future<?> future, Class<? extends 
Throwable> exceptionClass)
-        throws InterruptedException {
-        try {
-            future.get();
-            fail("Expected a " + exceptionClass.getSimpleName() + " exception, 
but got success.");
-        } catch (ExecutionException ee) {
-            Throwable cause = ee.getCause();
-            assertEquals(exceptionClass, cause.getClass(),

Review Comment:
   The remaining method uses `assertThrows`, appears as follows:
   
   ```java
   private static <T extends Throwable> T assertThrows(Class<T> expectedType, 
Executable executable, Object messageOrSupplier) {
     try {
       executable.execute();
     }
     catch (Throwable actualException) {
       if (expectedType.isInstance(actualException)) {
         return (T) actualException;
       }
       else {
         UnrecoverableExceptions.rethrowIfUnrecoverable(actualException);
         throw assertionFailure() //
           .message(messageOrSupplier) //
           .expected(expectedType) //
           .actual(actualException.getClass()) //
           .reason("Unexpected exception type thrown") //
           .cause(actualException) //
           .build();
       }
     }
     throw assertionFailure() //
       .message(messageOrSupplier) //
       .reason(format("Expected %s to be thrown, but nothing was thrown.", 
getCanonicalName(expectedType))) //
       .build();
   }
   ```
   
   This implementation seems to have the same effect as the `assertFutureError` 
method in 
[TestUtils.java](https://github.com/peterxcli/kafka/blob/b4be1785998d382843002ffd8685d67fe8d9c97d/clients/src/test/java/org/apache/kafka/test/TestUtils.java#L586-L597)
   
   Would like to know your thoughts on this. Thanks!



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