From 8e52e80399495e40321c3fb5a3c9835c5e5db1c7 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 16 Mar 2019 10:30:16 +0100 Subject: [PATCH] Synchronize later in notifyConnectionError(Exception) especially *after* the sync points have been notified so that a potential thread currently callin gconnect()/login() throws and leaves the synchronized section. This commit is more or less equivalent to 3ded023629e1d90365d95e2857230a8086d4e67a of the 4.3 branch. --- .../smack/AbstractXMPPConnection.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 53236e6b1..49b1e516f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -858,9 +858,6 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { ASYNC_BUT_ORDERED.performAsyncButOrdered(this, () -> { currentConnectionException = exception; - synchronized (AbstractXMPPConnection.this) { - notifyAll(); - } for (StanzaCollector collector : collectors) { collector.notifyConnectionError(exception); @@ -873,10 +870,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { // XMPPTCPConnection. Create delegation method? // maybeCompressFeaturesReceived.reportGenericFailure(smackWrappedException); - // Closes the connection temporary. A if the connection supports stream management, then a reconnection is - // possible. Note that a connection listener of e.g. XMPPTCPConnection will drop the SM state in - // case the Exception is a StreamErrorException. - instantShutdown(); + synchronized (AbstractXMPPConnection.this) { + notifyAll(); + + // Closes the connection temporary. A if the connection supports stream management, then a reconnection is + // possible. Note that a connection listener of e.g. XMPPTCPConnection will drop the SM state in + // case the Exception is a StreamErrorException. + instantShutdown(); + } Async.go(() -> { // Notify connection listeners of the error.