spotbugs / discuss

SpotBugs mailing list
6 stars 1 forks source link

Bug type OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE #81

Open anand-iisl opened 4 years ago

anand-iisl commented 4 years ago

False positive

    Connection conn         = null;
    PreparedStatement ps    = null;
    ResultSet rs            = null;
    String retVal           = "";
    try 
    {
        DbBean db = new DbBean();
        conn = db.getconnection();

        String query = "SELECT VALUE FROM SETTINGS WHERE ATTRIBUTE=?";
        ps = conn.prepareStatement(query);
        ps.setString(1,"PORT");
        rs=ps.executeQuery();
        if(rs.next()) 
        {
            String value = rs.getString(1).trim();
            if(value.equals("") || rs.getString(1)== null) 
            {
                System.out.println("Failed To get Value for Attribute :"+Attribute);
            }
            else
                retVal= value;
        }
    }
    catch (Exception e) 
    {
        e.printStackTrace();
    }
    finally {try {if(rs!=null) {rs.close();rs=null;}if(ps!=null) {ps.close();ps=null;}if(conn!=null) {conn.close();conn=null;}} catch (Exception e2) {e2.printStackTrace();}}
    return retVal;

===========