RFR: CODETOOLS-7902838: JMH: Don't use fail() inside a try-catch catching an AssertionError

Aleksey Shipilev shade at openjdk.java.net
Tue Mar 9 14:03:25 UTC 2021


SonarCloud instance reports a bug in our tests:
 "Don't use fail() inside a try-catch catching an AssertionError."

    @Test
    public void invokeAPI() throws RunnerException {
        try {
            ...
            new Runner(opt).run();

            Assert.fail("Should have failed"); // <--- here
        } catch (RunnerException e) {
            // expected
        }
    }

Indeed, that does not look correct.

-------------

Commit messages:
 - CODETOOLS-7902838: JMH: Don't use fail() inside a try-catch catching an AssertionError

Changes: https://git.openjdk.java.net/jmh/pull/25/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jmh&pr=25&range=00
  Issue: https://bugs.openjdk.java.net/browse/CODETOOLS-7902838
  Stats: 105 lines in 44 files changed: 0 ins; 0 del; 105 mod
  Patch: https://git.openjdk.java.net/jmh/pull/25.diff
  Fetch: git fetch https://git.openjdk.java.net/jmh pull/25/head:pull/25

PR: https://git.openjdk.java.net/jmh/pull/25


More information about the jmh-dev mailing list