zhuzhurk commented on code in PR #20222:
URL: https://github.com/apache/flink/pull/20222#discussion_r919780477


##########
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/SlotSharingExecutionSlotAllocatorTest.java:
##########
@@ -221,24 +204,26 @@ public void testReturningLogicalSlotsRemovesSharedSlot() 
throws Exception {
     }
 
     @Test
-    public void 
testLogicalSlotCancelsPhysicalSlotRequestAndRemovesSharedSlot() throws 
Exception {
+    void testLogicalSlotCancelsPhysicalSlotRequestAndRemovesSharedSlot() 
throws Exception {
         // physical slot request is not completed and does not complete 
logical requests
         testLogicalSlotRequestCancellationOrRelease(
                 true,
                 true,
                 (context, assignment) -> {
                     
context.getAllocator().cancel(assignment.getExecutionAttemptId());
-                    try {
-                        assignment.getLogicalSlotFuture().get();
-                        fail("The logical future must finish with the 
cancellation exception");
-                    } catch (InterruptedException | ExecutionException e) {
-                        assertThat(e.getCause(), 
instanceOf(CancellationException.class));
-                    }
+                    assertThatThrownBy(
+                                    () -> {
+                                        context.getAllocator()
+                                                
.cancel(assignment.getExecutionAttemptId());
+                                        
assignment.getLogicalSlotFuture().get();
+                                    })
+                            .as("The logical future must finish with the 
cancellation exception.")
+                            .hasCauseInstanceOf(CancellationException.class);

Review Comment:
   They both can work. However, I think `hasCauseInstanceOf` is more accurate 
as a translation of the original logic.



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