Repository: phoenix
Updated Branches:
  refs/heads/master 4b42f16b2 -> ec02daf34


PHOENIX-2898 HTable not closed in ConnectionQueryServicesImpl (Alex Araujo)


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

Branch: refs/heads/master
Commit: 94c4b2a08296f3e6948e028cceeb5c3472b7e2c9
Parents: 3de0170
Author: James Taylor <[email protected]>
Authored: Thu May 26 14:41:23 2016 -0700
Committer: James Taylor <[email protected]>
Committed: Thu Jun 9 08:00:10 2016 -0700

----------------------------------------------------------------------
 .../phoenix/query/ConnectionQueryServicesImpl.java      | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/94c4b2a0/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 c29c0bf..8592a7f 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
@@ -1156,6 +1156,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
         boolean isIncompatible = false;
         int minHBaseVersion = Integer.MAX_VALUE;
         boolean isTableNamespaceMappingEnabled = false;
+        HTableInterface ht = null;
         try {
             List<HRegionLocation> locations = this
                     .getAllTableRegions(metaTable);
@@ -1170,8 +1171,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                 }
             }
 
-            HTableInterface ht = this
-                    .getTable(metaTable);
+            ht = this.getTable(metaTable);
             final Map<byte[], Long> results =
                     ht.coprocessorService(MetaDataService.class, null, null, 
new Batch.Call<MetaDataService,Long>() {
                         @Override
@@ -1219,6 +1219,14 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
             throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.INCOMPATIBLE_CLIENT_SERVER_JAR).setRootCause(t)
                 .setMessage("Ensure that " + 
QueryConstants.DEFAULT_COPROCESS_PATH + " is put on the classpath of HBase in 
every region server: " + t.getMessage())
                 .build().buildException();
+        } finally {
+            if (ht != null) {
+                try {
+                    ht.close();
+                } catch (IOException e) {
+                    logger.warn("Could not close HTable", e);
+                }
+            }
         }
         if (isIncompatible) {
             buf.setLength(buf.length()-1);

Reply via email to