Repository: phoenix Updated Branches: refs/heads/master e463a22cb -> 90b9ec8ec
PHOENIX-1141 Fix HTable resource leak in ConnectionQueryServicesImpl.metaDataCoprocessorExec (SamarthJain) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/90b9ec8e Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/90b9ec8e Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/90b9ec8e Branch: refs/heads/master Commit: 90b9ec8ec914e3d1ee04f4154d57cd3fe80856b7 Parents: e463a22 Author: Mujtaba <mujt...@apache.org> Authored: Fri Aug 1 11:19:25 2014 -0700 Committer: Mujtaba <mujt...@apache.org> Committed: Fri Aug 1 11:19:25 2014 -0700 ---------------------------------------------------------------------- .../query/ConnectionQueryServicesImpl.java | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/90b9ec8e/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 93cb241..066e753 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 @@ -26,7 +26,6 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAM import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; import java.io.IOException; -import java.sql.Connection; import java.sql.SQLException; import java.util.Collections; import java.util.List; @@ -885,17 +884,21 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement } HTableInterface ht = this.getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); - final Map<byte[], MetaDataResponse> results = - ht.coprocessorService(MetaDataService.class, tableKey, tableKey, callable); - - assert(results.size() == 1); - MetaDataResponse result = results.values().iterator().next(); - if (result.getReturnCode() == MetaDataProtos.MutationCode.TABLE_NOT_IN_REGION) { - if (retried) return MetaDataMutationResult.constructFromProto(result); - retried = true; - continue; + try { + final Map<byte[], MetaDataResponse> results = + ht.coprocessorService(MetaDataService.class, tableKey, tableKey, callable); + + assert(results.size() == 1); + MetaDataResponse result = results.values().iterator().next(); + if (result.getReturnCode() == MetaDataProtos.MutationCode.TABLE_NOT_IN_REGION) { + if (retried) return MetaDataMutationResult.constructFromProto(result); + retried = true; + continue; + } + return MetaDataMutationResult.constructFromProto(result); + } finally { + Closeables.closeQuietly(ht); } - return MetaDataMutationResult.constructFromProto(result); } } catch (IOException e) { throw ServerUtil.parseServerException(e);