From efb9a5f517b4fd57444b55f660b698c40a5f30cf Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 19 Dec 2014 12:54:07 +0100 Subject: [PATCH] Improve logging of finalize() methods --- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 2 ++ .../main/java/org/jivesoftware/smackx/ping/PingManager.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 76cf34087..1d2175f2d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -1057,6 +1057,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { @Override protected void finalize() throws Throwable { + LOGGER.fine("finalizing XMPPConnection ( " + getConnectionCounter() + + "): Shutting down executor services"); try { // It's usually not a good idea to rely on finalize. But this is the easiest way to // avoid the "Smack Listener Processor" leaking. The thread(s) of the executor have a diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java index b41efaa4f..996220f96 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java @@ -404,9 +404,13 @@ public class PingManager extends Manager { @Override protected void finalize() throws Throwable { + LOGGER.fine("finalizing PingManager: Shutting down executor service"); try { executorService.shutdown(); - } finally { + } catch (Throwable t) { + LOGGER.log(Level.WARNING, "finalize() threw throwable", t); + } + finally { super.finalize(); } }