ABSTRACT

Empty try blocks are either dead code or indicate the presence of debug code.

EXPLANATION

An empty try block serves no functional purpose. In fact, when compiled to byte code, the empty try block is optimized out and never makes it into the finished program. An empty try block might be indicative of code that has been removed or commented out.
Example 1: The following code contains an empty try block.


try {
//rs = stmt.executeQuery(query);
}
catch(SQLException e) {
log(e);
}

Dead code negatively impacts code quality, making code harder to read, understand, and maintain.

REFERENCES

[1] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3050 CAT II

[2] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 561

[3] Sun Microsystems, Inc. Java Sun Tutorial