From fd1b49ca8f5d3b8918101f66549c5688b674ca10 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 12 Jun 2020 18:15:24 +0200 Subject: [PATCH] [tcp] Set sync points before they are used, and not in init() --- .../jivesoftware/smack/tcp/XMPPTCPConnection.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 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 b641fd183..8faaf30d9 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 @@ -364,6 +364,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { SmackException, IOException, InterruptedException { // Authenticate using SASL SSLSession sslSession = secureSocket != null ? secureSocket.getSession() : null; + + streamFeaturesAfterAuthenticationReceived = false; authenticate(username, password, config.getAuthzid(), sslSession); // Wait for stream features after the authentication. @@ -375,6 +377,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // recommends to perform stream compression before resource binding. maybeEnableCompression(); + smResumedSyncPoint = SyncPointState.initial; + smResumptionFailed = null; if (isSmResumptionPossible()) { smResumedSyncPoint = SyncPointState.request_sent; sendNonza(new Resume(clientHandledStanzasCount, smSessionId)); @@ -409,6 +413,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // unacknowledgedStanzas and become duplicated on reconnect. See SMACK-706. bindResourceAndEstablishSession(resource); + smEnabledSyncPoint = false; if (isSmAvailable() && useSm) { // Remove what is maybe left from previously stream managed sessions serverHandledStanzasCount = 0; @@ -535,15 +540,6 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { initState(); } - @Override - protected void initState() { - super.initState(); - streamFeaturesAfterAuthenticationReceived = compressSyncPoint = false; - smResumedSyncPoint = SyncPointState.initial; - smResumptionFailed = null; - smEnabledSyncPoint = false; - } - @Override public void sendNonza(Nonza element) throws NotConnectedException, InterruptedException { packetWriter.sendStreamElement(element); @@ -794,6 +790,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { // If stream compression was offered by the server and we want to use // compression then send compression request to the server if ((compressionHandler = maybeGetCompressionHandler(compression)) != null) { + compressSyncPoint = false; sendNonza(new Compress(compressionHandler.getCompressionMethod())); waitForConditionOrThrowConnectionException(() -> compressSyncPoint, "establishing stream compression"); } else {