Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
Description
Flink uses AssertJ incorrectly:
- Multiple tests callĀ AssertJ's withFailMessage at the end, for example something like this:
assertThat(...) ...() .withFailMessage("Some message");
However, the withFailMessage documentation says:
You must set it before calling the assertion otherwise it is ignored as the failing assertion breaks the chained call by throwing an AssertionError.
This can be seen for example with the following code where the custom message is ignored:
assertThat(false).isTrue().withFailMessage("Some message");
There are 20+ cases of this in the Flink code so I am not going to list them here, hoping that it is easier to find them yourself. Though please let me know if I should list them here.
- No assertion being performed by WebFrontendITCase. There are (currently) three cases where accidentally no call is made on the assertThat return value. For example something like this:
assertThat(list.isEmpty()); // Should instead be assertThat(list).isEmpty();
- https://github.com/apache/flink/blob/bfe49b2973d4ffc8f7404a376cab1e419b53406a/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/WebFrontendITCase.java#L302-L302
- https://github.com/apache/flink/blob/bfe49b2973d4ffc8f7404a376cab1e419b53406a/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/WebFrontendITCase.java#L372-L372
- https://github.com/apache/flink/blob/bfe49b2973d4ffc8f7404a376cab1e419b53406a/flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/WebFrontendITCase.java#L416-L416
I found those because AssertJ is luckily using @CheckReturnValue on their API. I assume SpotBugs, Error Prone or IntelliJ IDEA might have found these issues as well, in case you want to investigate integrating automatic detection of such errors.
Attachments
Issue Links
- links to