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/37279e24 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/37279e24 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/37279e24 Branch: refs/heads/4.x-HBase-1.0 Commit: 37279e2472d6c1edd5a51ee0be0b90231861e3bd Parents: 2c0b7c7 Author: James Taylor <[email protected]> Authored: Thu May 26 14:41:23 2016 -0700 Committer: James Taylor <[email protected]> Committed: Thu Jun 9 11:26:29 2016 -0700 ---------------------------------------------------------------------- .../phoenix/query/ConnectionQueryServicesImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/37279e24/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 7e3cbba..68f426a 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 @@ -1150,6 +1150,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); @@ -1164,8 +1165,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 @@ -1213,6 +1213,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);
