You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sa...@apache.org on 2016/09/27 23:46:11 UTC

phoenix git commit: PHOENIX-3334 ConnectionQueryServicesImpl should close HConnection if init fails

Repository: phoenix
Updated Branches:
  refs/heads/4.8-HBase-0.98 cc93b560f -> 3ce8e564e


PHOENIX-3334 ConnectionQueryServicesImpl should close HConnection if init fails


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

Branch: refs/heads/4.8-HBase-0.98
Commit: 3ce8e564e455afe4453315dba549cb78a0adaf54
Parents: cc93b56
Author: Samarth <sa...@salesforce.com>
Authored: Tue Sep 27 16:46:01 2016 -0700
Committer: Samarth <sa...@salesforce.com>
Committed: Tue Sep 27 16:46:01 2016 -0700

----------------------------------------------------------------------
 .../query/ConnectionQueryServicesImpl.java      | 25 +++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3ce8e564/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 3fd812f..3dbbf09 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -2311,8 +2311,10 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                         boolean success = false;
                         String snapshotName = null;
                         String sysCatalogTableName = null;
+                        boolean hConnectionEstablished = false;
                         try {
                             openConnection();
+                            hConnectionEstablished = true;
                             String noUpgradeProp = props.getProperty(PhoenixRuntime.NO_UPGRADE_ATTRIB);
                             boolean upgradeSystemTables = !Boolean.TRUE.equals(Boolean.valueOf(noUpgradeProp));
                             Properties scnProps = PropertiesUtil.deepCopy(props);
@@ -2593,13 +2595,24 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
                                     } else {
                                         initializationException = e;
                                     }
-                                }
-                                try {
-                                    if (initializationException != null) {
-                                        throw initializationException;
-                                    }
                                 } finally {
-                                    initialized = true;
+                                    try {
+                                        if (!success && hConnectionEstablished) {
+                                            connection.close();
+                                        }
+                                    } catch (IOException e) {
+                                        SQLException ex = new SQLException(e);
+                                        if (initializationException != null) {
+                                            initializationException.setNextException(ex);
+                                        } else {
+                                            initializationException = ex;
+                                        }
+                                    } finally {
+                                        initialized = true;
+                                        if (initializationException != null) {
+                                            throw initializationException;
+                                        }
+                                    }
                                 }
                             }
                         }