From b90795e142b490549db86a40007f3eab813bc67c Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Wed, 10 May 2017 15:56:01 -0500 Subject: [POLICY-12] tackle policy-persistence/DBaudit.java 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 --- .../src/main/java/org/openecomp/policy/drools/core/DbAudit.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/policy-persistence/src/main/java/org/openecomp/policy/drools/core/DbAudit.java b/policy-persistence/src/main/java/org/openecomp/policy/drools/core/DbAudit.java index 51e92aa9..f534cc22 100644 --- a/policy-persistence/src/main/java/org/openecomp/policy/drools/core/DbAudit.java +++ b/policy-persistence/src/main/java/org/openecomp/policy/drools/core/DbAudit.java @@ -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) { -- cgit 1.2.3-korg