From 7059b60672628d1427776a794d396fb09b2ed42b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 16 Mar 2019 11:11:58 +0100 Subject: [PATCH] Wait for reader/writer thread termination at the end of shutdown() This synchronizes the place with what the master branch currently does. --- .../org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 b0fcb8b7d..bf4409506 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 @@ -561,6 +561,10 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { writer = null; initState(); + + // Wait for reader and writer threads to be terminated. + readerWriterSemaphore.acquireUninterruptibly(2); + readerWriterSemaphore.release(2); } @Override @@ -978,10 +982,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // Note that a connection listener of XMPPTCPConnection will drop the SM state in // case the Exception is a StreamErrorException. instantShutdown(); - - // Wait for reader and writer threads to be terminated. - readerWriterSemaphore.acquireUninterruptibly(2); - readerWriterSemaphore.release(2); } Async.go(new Runnable() {