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/ad7f18e0 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ad7f18e0 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ad7f18e0 Branch: refs/heads/4.x-HBase-0.98 Commit: ad7f18e0f2abef8e27a12635cfe1aed745486119 Parents: 6e12ccf Author: James Taylor <[email protected]> Authored: Thu May 26 14:41:23 2016 -0700 Committer: James Taylor <[email protected]> Committed: Thu Jun 9 11:29:15 2016 -0700 ---------------------------------------------------------------------- .../phoenix/query/ConnectionQueryServicesImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ad7f18e0/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 9092bca..62ffeb5 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 @@ -1151,6 +1151,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); @@ -1165,8 +1166,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 @@ -1214,6 +1214,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);
