False Negative for CloseResource rule.
A source code analyzer
                
                Brought to you by:
                
                    adangel,
                    
                
                    juansotuyo
                    
                
            
            
        
        
        
    CloseResource is not flagging violations
Rule Definition:
<rule ref="rulesets/java/design.xml/CloseResource">
    <properties>
        <property name="types" value="Connection,Statement,ResultSet,PreparedStatement"/>
        <property name="closeTargets" value="closeLocalResources,closeResultSet" />
    </properties>
</rule>
*The below code is missing the closure of the ResultSet object.
Even tested removing the entire finally block and still no PMD issue was found.  *
public Object selectOne(final int val, final int val2) {
    getCurrentSession().doWork(new Work() {
    @Override
    public void execute(Connection connection) throws SQLException {            
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            stmt = createDefaultPreparedStatement(connection, CONSTANTS.QUERY_STRING);
            stmt.setInt(1, vaL);
            stmt.setInt(2, val2);
            rs = stmt.executeQuery();
                /do result set processing
        } catch (SQLException se) {
            //error
        } finally {
            closeLocalResources(stmt);  
        }
    }
    });
}
Thanks for the bug report. It turns out, that [#1375] is a duplicate.
Workaround is: do not initialize the variable with null - just define the variable.
This will be fixed with pmd 5.3.3.
Related
Issues:
#1375