From f9292a23fbdec8612e9e2554a2068cf6b1e86dc5 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Tue, 16 Jun 2020 22:59:26 +0200 Subject: [PATCH] [tcp] Add and improve log of reader/writer thread termination --- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index c5328798a..99c6d2953 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -500,18 +500,18 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { if (!packetWriter.done()) { // First shutdown the writer, this will result in a closing stream element getting send to // the server - LOGGER.finer("PacketWriter shutdown()"); + LOGGER.finer(packetWriter.threadName + " shutdown()"); packetWriter.shutdown(instant); - LOGGER.finer("PacketWriter has been shut down"); + LOGGER.finer(packetWriter.threadName + " shutdown() returned"); if (!instant) { waitForClosingStreamTagFromServer(); } } - LOGGER.finer("PacketReader shutdown()"); + LOGGER.finer(packetReader.threadName + " shutdown()"); packetReader.shutdown(); - LOGGER.finer("PacketReader has been shut down"); + LOGGER.finer(packetReader.threadName + " shutdown() returned"); CloseableUtil.maybeClose(socket, LOGGER); @@ -520,7 +520,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { try { boolean readerAndWriterThreadsTermianted = waitForCondition(() -> !packetWriter.running && !packetReader.running); if (!readerAndWriterThreadsTermianted) { - LOGGER.severe("Reader and writer threads did not terminate"); + LOGGER.severe("Reader and/or writer threads did not terminate timely. Writer running: " + + packetWriter.running + ", Reader running: " + packetReader.running); + } else { + LOGGER.fine("Reader and writer threads terminated"); } } catch (InterruptedException e) { LOGGER.log(Level.FINE, "Interrupted while waiting for reader and writer threads to terminate", e);