rkhachatryan commented on a change in pull request #12525:
URL: https://github.com/apache/flink/pull/12525#discussion_r441486641



##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
##########
@@ -207,9 +207,12 @@ public void testCleanUpExceptionSuppressing() throws 
Exception {
                        testHarness.waitForTaskCompletion();
                }
                catch (Exception ex) {
-                       if (!ExceptionUtils.findThrowable(ex, 
ExpectedTestException.class).isPresent()) {
-                               throw ex;
-                       }
+                       Assert.assertTrue(ex.getCause() instanceof 
ExpectedTestException);
+                       Assert.assertTrue(

Review comment:
       nit: IDE suggests to replace `assertTrue` with `assertEquals`

##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
##########
@@ -207,9 +207,12 @@ public void testCleanUpExceptionSuppressing() throws 
Exception {
                        testHarness.waitForTaskCompletion();
                }
                catch (Exception ex) {
-                       if (!ExceptionUtils.findThrowable(ex, 
ExpectedTestException.class).isPresent()) {
-                               throw ex;
-                       }
+                       Assert.assertTrue(ex.getCause() instanceof 
ExpectedTestException);
+                       Assert.assertTrue(
+                               ex.getCause()
+                                       .getSuppressed()[0]
+                                       .getMessage()
+                                       .equals("Dispose Exception. This 
exception should be suppressed"));

Review comment:
       Can we pass `expectedException` object to `FailingTwiceOperator` 
constructor and compare objects here rather than messages? It would be less 
fragile and more clear IMO.

##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
##########
@@ -207,9 +207,12 @@ public void testCleanUpExceptionSuppressing() throws 
Exception {
                        testHarness.waitForTaskCompletion();
                }
                catch (Exception ex) {
-                       if (!ExceptionUtils.findThrowable(ex, 
ExpectedTestException.class).isPresent()) {
-                               throw ex;
-                       }
+                       Assert.assertTrue(ex.getCause() instanceof 
ExpectedTestException);
+                       Assert.assertTrue(
+                               ex.getCause()
+                                       .getSuppressed()[0]

Review comment:
       nit: `getOnlyElement(asList(ex.getCause().getSuppressed()))`
   
   I think this way it would be more readable and safe.
   
   
(`org.apache.flink.shaded.guava18.com.google.common.collect.Iterables.getOnlyElement`)




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

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


Reply via email to