[POLICY-12] tackle policy-persistence/DBaudit.java 11/4111/1
authorJorge Hernandez <jh1730@att.com>
Wed, 10 May 2017 20:56:01 +0000 (15:56 -0500)
committerJorge Hernandez <jh1730@att.com>
Wed, 10 May 2017 20:56:01 +0000 (15:56 -0500)
Deals with the following reports:

Description Resource Path Location Type
Resource leak: 'statement' is not closed at this location DbAudit.java
/policy-persistence/src/main/java/org/openecomp/policy/drools/core
line 135 Java Problem

Description Resource Path Location Type
Resource leak: 'statement' is not closed at this location DbAudit.java
/policy-persistence/src/main/java/org/openecomp/policy/drools/core
line 142 Java Problem

Description Resource Path Location Type
Resource leak: 'statement' is not closed at this location DbAudit.java
/policy-persistence/src/main/java/org/openecomp/policy/drools/core
line 160 Java Problem

Change-Id: I16c6698ee9b659add11d3bc62abb38a3d1792049
Signed-off-by: Jorge Hernandez <jh1730@att.com>
policy-persistence/src/main/java/org/openecomp/policy/drools/core/DbAudit.java

index 51e92aa..f534cc2 100644 (file)
@@ -126,6 +126,7 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
                           + " UNIQUE KEY name (name)\n"
                           + ") DEFAULT CHARSET=latin1;");
                        statement.execute();
+                       statement.close();
                        createTableNeeded = false;
                  }
 
@@ -136,6 +137,7 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
                  ("INSERT INTO Audit (name) VALUES (?)");
                statement.setString(1, key);
                statement.executeUpdate();
+               statement.close();
 
                // fetch the entry from the table
                phase = "fetch entry";
@@ -154,6 +156,7 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
                          ("DbAudit: can't find newly-created entry with key " + key);
                        setResponse("Can't find newly-created entry");
                  }
+               statement.close();
 
                // delete entries from table
                phase = "delete entry";
@@ -161,6 +164,8 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
                  ("DELETE FROM Audit WHERE name = ?");
                statement.setString(1, key);
                statement.executeUpdate();
+               statement.close();
+               statement = null;
          }
        catch (Exception e)
          {