ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-12165 Don't overwrite Statement variable before previous statement is closed (dsen)
Date Fri, 26 Jun 2015 13:24:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 16ecb5bb2 -> cba114fe2


AMBARI-12165 Don't overwrite Statement variable before previous statement is closed (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cba114fe
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cba114fe
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cba114fe

Branch: refs/heads/branch-2.1
Commit: cba114fe25565058893e556aa38555799ebba20a
Parents: 16ecb5b
Author: Dmytro Sen <dsen@apache.org>
Authored: Fri Jun 26 16:21:34 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Fri Jun 26 16:23:45 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ambari/server/upgrade/UpgradeCatalog210.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cba114fe/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
index 66c03fa..c485e02 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java
@@ -886,9 +886,11 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
         HOSTS_TABLE, HOST_ID_COL, CLUSTER_HOST_MAPPING_TABLE);
     ResultSet hostsNotInCluster = null;
     Statement statement = null;
+    Statement duplicatedHostsStatement = null;
 
     try {
       statement = dbAccessor.getConnection().createStatement();
+      duplicatedHostsStatement = dbAccessor.getConnection().createStatement();
       hostsNotInCluster = statement.executeQuery(hostsNotInClusterQuery);
       if(hostsNotInCluster != null) {
         while (hostsNotInCluster.next()) {
@@ -898,8 +900,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
           long count = 0;
           ResultSet duplicateHosts = null;
           try {
-            statement = dbAccessor.getConnection().createStatement();
-            duplicateHosts = statement.executeQuery(duplicateHostsQuery);
+            duplicateHosts = duplicatedHostsStatement.executeQuery(duplicateHostsQuery);
             if (duplicateHosts != null && duplicateHosts.next()) {
               count = duplicateHosts.getLong(1);
             }
@@ -924,6 +925,9 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
       if (statement != null) {
         statement.close();
       }
+      if (duplicatedHostsStatement != null) {
+        duplicatedHostsStatement.close();
+      }
     }
   }
 


Mime
View raw message