From a914f2efebd0ee1effa962f1068beffa1b9c620f Mon Sep 17 00:00:00 2001 From: mokai Date: Fri, 21 Aug 2020 21:19:02 +0800 Subject: [PATCH] HBASE-24686 [LOG] Log improvement in Connection#close (#2219) Signed-off-by: Pankaj Kumar Signed-off-by: Viraj Jasani Signed-off-by: Sean Busbey --- .../hadoop/hbase/client/AsyncConnectionImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java index 039ff4d12f8..83193600f01 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java @@ -192,6 +192,10 @@ class AsyncConnectionImpl implements AsyncConnection { if (closed) { return; } + LOG.info("Connection has been closed by {}.", Thread.currentThread().getName()); + if(LOG.isDebugEnabled()){ + logCallStack(Thread.currentThread().getStackTrace()); + } IOUtils.closeQuietly(clusterStatusListener); IOUtils.closeQuietly(rpcClient); IOUtils.closeQuietly(registry); @@ -202,6 +206,16 @@ class AsyncConnectionImpl implements AsyncConnection { closed = true; } + private void logCallStack(StackTraceElement[] stackTraceElements) { + StringBuilder stackBuilder = new StringBuilder("Call stack:"); + for (StackTraceElement element : stackTraceElements) { + stackBuilder.append("\n at "); + stackBuilder.append(element); + } + stackBuilder.append("\n"); + LOG.debug(stackBuilder.toString()); + } + @Override public boolean isClosed() { return closed;