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 c268338d66e..888632061f6 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 @@ -484,6 +484,16 @@ private void openConnection() throws SQLException { } } + // Close the HBase Connection + private void closeConnection() throws IOException { + if (connection != null) { + connection.close(); + LOGGER.info("HConnection closed. Stacktrace for informational purposes: " + + connection + " " + LogUtil.getCallerStackTrace()); + } + GLOBAL_HCONNECTIONS_COUNTER.decrement(); + } + @Override public Table getTable(byte[] tableName) throws SQLException { try { @@ -571,8 +581,7 @@ public void close() throws SQLException { } try { // close the HBase connection - if (connection != null) connection.close(); - GLOBAL_HCONNECTIONS_COUNTER.decrement(); + closeConnection(); } finally { if (renewLeaseExecutor != null) { renewLeaseExecutor.shutdownNow(); @@ -3322,7 +3331,7 @@ Collections.> singletonList( } finally { try { if (!success && hConnectionEstablished) { - connection.close(); + closeConnection(); } } catch (IOException e) { SQLException ex = new SQLException(e);