Skip to content

Files

Latest commit

 

History

History
23 lines (16 loc) · 560 Bytes

AssertWithinFinallyBlock.md

File metadata and controls

23 lines (16 loc) · 560 Bytes

Pattern: Assert within finally block

Issue: -

Description

Checks for assert statements within a finally block. An assert can throw an exception, hiding the original exception, if there is one.

Here is an example of code that produces a violation:

int someMethod(int count) {
    try {
        doSomething()
    } finally {
        assert count > 0        // violation
    }
}

Further Reading