Jiabao-Sun commented on code in PR #23242: URL: https://github.com/apache/flink/pull/23242#discussion_r1299393443
########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -87,14 +79,19 @@ public void testConnectionTimeout() throws Exception { EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance()); - final Throwable cause = assertThrows(ExecutionException.class, future::get).getCause(); - assertThat(cause, instanceOf(ConnectTimeoutException.class)); - assertThat(cause.getMessage(), containsString(unroutableIp)); + try { + future.get(); + fail("Expected exception not thrown."); + } catch (ExecutionException e) { + final Throwable cause = e.getCause(); + assertThat(cause).isInstanceOf(ConnectTimeoutException.class); + assertThat(cause.getMessage()).contains(unroutableIp); + } Review Comment: ```suggestion assertThatFuture(future) .eventuallyFailsWith(ExecutionException.class) .withCauseInstanceOf(ConnectTimeoutException.class) .withMessageContaining(unroutableIp); ``` ########## flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestClientTest.java: ########## @@ -106,15 +103,15 @@ public void testInvalidVersionRejection() throws Exception { EmptyRequestBody.getInstance(), Collections.emptyList(), RuntimeRestAPIVersion.V0); - Assert.fail("The request should have been rejected due to a version mismatch."); + fail("Expected exception not thrown."); } catch (IllegalArgumentException e) { Review Comment: ```suggestions assertThatThrownBy(() -> restClient.sendRequest( unroutableIp, 80, new TestMessageHeaders(), EmptyMessageParameters.getInstance(), EmptyRequestBody.getInstance(), Collections.emptyList(), RuntimeRestAPIVersion.V0)) .isInstanceOf(IllegalArgumentException.class); ``` By the way, would you mind to change all this pattern of expecting an exception? -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org