1318
Do not use a return statement inside the finally block. The finally block should have "cleanup"
code.
Demonstrative Examples
Example 1:
In the following code excerpt, the IllegalArgumentException will never be delivered to the caller.
The finally block will cause the exception to be discarded.
Example Language: Java (Bad)
try {
...
throw IllegalArgumentException();
}
finally {
return r;
}
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 851 The CERT Oracle Secure Coding Standard for Java
(2011) Chapter 8 - Exceptional Behavior (ERR)
844 2365
MemberOf 961 SFP Secondary Cluster: Incorrect Exception Behavior 888 2399
MemberOf 1141 SEI CERT Oracle Secure Coding Standard for Java -
Guidelines 07. Exceptional Behavior (ERR)
1133 2448
MemberOf 1410 Comprehensive Categorization: Insufficient Control
Flow Management
1400 2536
Taxonomy Mappings
Mapped Taxonomy Name Node ID Fit Mapped Node Name
The CERT Oracle Secure
Coding Standard for Java
(2011)
ERR04-J Do not complete abruptly from a finally
block
The CERT Oracle Secure
Coding Standard for Java
(2011)
ERR05-J Do not let checked exceptions escape
from a finally block
Software Fault Patterns SFP6 Incorrect Exception Behavior
CWE-585: Empty Synchronized Block
Weakness ID : 585
Structure : Simple
Abstraction : Variant
Description
The product contains an empty synchronized block.
Extended Description
An empty synchronized block does not actually accomplish any synchronization and may indicate a
troubled section of code. An empty synchronized block can occur because code no longer needed
within the synchronized block is commented out without removing the synchronized block.
CWE Version 4.14
CWE-585: Empty Synchronized Block
CWE-585: Empty Synchronized Block