From 810e7c8b7824bf9a26d0ce5341538390b2d6233b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 5 Sep 2016 14:56:40 +0200 Subject: [PATCH] Prevent GC of connection within pingServerIfNecessary() --- .../main/java/org/jivesoftware/smackx/ping/PingManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 fe4a7b860..0171a1095 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 @@ -377,7 +377,10 @@ public final class PingManager extends Manager { res = pingMyServer(false); } catch (InterruptedException | SmackException e) { - LOGGER.log(Level.WARNING, "Exception while pinging server", e); + // Note that we log the connection here, so that it is not GC'ed between the call to isAuthenticated + // a few lines above and the usage of the connection within pingMyServer(). In order to prevent: + // https://community.igniterealtime.org/thread/59369 + LOGGER.log(Level.WARNING, "Exception while pinging server of " + connection, e); res = false; } // stop when we receive a pong back