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/f6edc9c1 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f6edc9c1 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f6edc9c1 Branch: refs/heads/4.x-HBase-1.1 Commit: f6edc9c1292c406fa8c6a89f23e4fc5dac7c38fd Parents: c87c7c4 Author: James Taylor <[email protected]> Authored: Thu May 26 14:41:23 2016 -0700 Committer: James Taylor <[email protected]> Committed: Thu Jun 9 11:22:51 2016 -0700 ---------------------------------------------------------------------- .../phoenix/query/ConnectionQueryServicesImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/f6edc9c1/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 f593dd0..888c481 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);
