From 31fb9fc57f7d97b1c248a94637c778fe67cb2004 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 e0b7407394f0..b4b8c65a9bfa 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 @@ -189,6 +189,10 @@ public void close() { 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); @@ -199,6 +203,16 @@ public void close() { 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;