Program: 105534
Project: 105534
Buggy source:
private void upgradeEgressFirewallRules(Connection conn){
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  ResultSet rsId=null;
  ResultSet rsNw=null;
  try {
    pstmt=conn.prepareStatement("String_Node_Str" + "String_Node_Str");
    s_logger.debug("String_Node_Str" + pstmt);
    pstmt.executeUpdate();
    pstmt=conn.prepareStatement("String_Node_Str");
    rs=pstmt.executeQuery();
    while (rs.next()) {
      long netId=rs.getLong(1);
      pstmt=conn.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      pstmt.setLong(1,netId);
      s_logger.debug("String_Node_Str" + pstmt);
      rsNw=pstmt.executeQuery();
      if (rsNw.next()) {
        long accountId=rsNw.getLong(1);
        long domainId=rsNw.getLong(2);
        s_logger.debug("String_Node_Str" + netId);
        pstmt=conn.prepareStatement("String_Node_Str");
        pstmt.setString(1,UUID.randomUUID().toString());
        pstmt.setLong(2,accountId);
        pstmt.setLong(3,domainId);
        pstmt.setLong(4,netId);
        pstmt.setString(5,UUID.randomUUID().toString());
        s_logger.debug("String_Node_Str" + pstmt);
        pstmt.executeUpdate();
        pstmt=conn.prepareStatement("String_Node_Str");
        pstmt.setLong(1,netId);
        rsId=pstmt.executeQuery();
        long firewallRuleId;
        if (rsId.next()) {
          firewallRuleId=rsId.getLong(1);
          pstmt=conn.prepareStatement("String_Node_Str");
          pstmt.setLong(1,firewallRuleId);
          s_logger.debug("String_Node_Str" + firewallRuleId + "String_Node_Str"+ pstmt);
          pstmt.executeUpdate();
        }
      }
    }
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
 finally {
    try {
      if (rs != null) {
        rs.close();
      }
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
}

Fixed version (ground truth):
private void upgradeEgressFirewallRules(Connection conn){
  try (PreparedStatement updateNwpstmt=conn.prepareStatement("String_Node_Str" + "String_Node_Str")){
    updateNwpstmt.executeUpdate();
    s_logger.debug("String_Node_Str" + updateNwpstmt);
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
  try (PreparedStatement vrNwpstmt=conn.prepareStatement("String_Node_Str");ResultSet vrNwsRs=vrNwpstmt.executeQuery()){
    while (vrNwsRs.next()) {
      long netId=vrNwsRs.getLong(1);
      try (PreparedStatement NwAcctDomIdpstmt=conn.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str")){
        NwAcctDomIdpstmt.setLong(1,netId);
        try (ResultSet NwAcctDomIdps=NwAcctDomIdpstmt.executeQuery()){
          s_logger.debug("String_Node_Str" + NwAcctDomIdpstmt);
          if (NwAcctDomIdps.next()) {
            long accountId=NwAcctDomIdps.getLong(1);
            long domainId=NwAcctDomIdps.getLong(2);
            s_logger.debug("String_Node_Str" + netId);
            try (PreparedStatement fwRulespstmt=conn.prepareStatement("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str")){
              fwRulespstmt.setString(1,UUID.randomUUID().toString());
              fwRulespstmt.setLong(2,accountId);
              fwRulespstmt.setLong(3,domainId);
              fwRulespstmt.setLong(4,netId);
              fwRulespstmt.setString(5,UUID.randomUUID().toString());
              s_logger.debug("String_Node_Str" + fwRulespstmt);
              fwRulespstmt.executeUpdate();
            }
 catch (            SQLException e) {
              throw new CloudRuntimeException("String_Node_Str",e);
            }
            try (PreparedStatement protoAllpstmt=conn.prepareStatement("String_Node_Str")){
              protoAllpstmt.setLong(1,netId);
              try (ResultSet protoAllRs=protoAllpstmt.executeQuery()){
                long firewallRuleId;
                if (protoAllRs.next()) {
                  firewallRuleId=protoAllRs.getLong(1);
                  try (PreparedStatement fwCidrsPstmt=conn.prepareStatement("String_Node_Str")){
                    fwCidrsPstmt.setLong(1,firewallRuleId);
                    s_logger.debug("String_Node_Str" + firewallRuleId + "String_Node_Str"+ fwCidrsPstmt);
                    fwCidrsPstmt.executeUpdate();
                  }
 catch (                  SQLException e) {
                    throw new CloudRuntimeException("String_Node_Str",e);
                  }
                }
              }
 catch (              SQLException e) {
                throw new CloudRuntimeException("String_Node_Str",e);
              }
            }
 catch (            SQLException e) {
              throw new CloudRuntimeException("String_Node_Str",e);
            }
          }
        }
 catch (        SQLException e) {
          throw new CloudRuntimeException("String_Node_Str",e);
        }
      }
 catch (      SQLException e) {
        throw new CloudRuntimeException("String_Node_Str",e);
      }
    }
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
}