From 0bcd3d9356232510ee22f2703bcfeb0936960234 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 18 Jan 2015 11:16:12 +0100 Subject: [PATCH] Synchronize connect() and login() Those methods being not synchronized was never an issue, but they should mutally exclusive and not be called multiple times concurrently. --- .../org/jivesoftware/smack/AbstractXMPPConnection.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 53c150b9b..321afa016 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -348,7 +348,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @throws IOException * @throws ConnectionException with detailed information about the failed connection. */ - public void connect() throws SmackException, IOException, XMPPException { + public synchronized void connect() throws SmackException, IOException, XMPPException { throwAlreadyConnectedExceptionIfAppropriate(); saslAuthentication.init(); saslFeatureReceived.init(); @@ -392,7 +392,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @throws SmackException if an error occurs somehwere else besides XMPP protocol level. * @throws IOException */ - public void login() throws XMPPException, SmackException, IOException { + public synchronized void login() throws XMPPException, SmackException, IOException { if (isAnonymous()) { throwNotConnectedExceptionIfAppropriate(); throwAlreadyLoggedInExceptionIfAppropriate(); @@ -418,7 +418,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @throws IOException * @see #login */ - public void login(String username, String password) throws XMPPException, SmackException, + public synchronized void login(String username, String password) throws XMPPException, SmackException, IOException { login(username, password, config.getResource()); } @@ -435,7 +435,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { * @throws IOException * @see #login */ - public void login(String username, String password, String resource) throws XMPPException, + public synchronized void login(String username, String password, String resource) throws XMPPException, SmackException, IOException { if (!config.allowNullOrEmptyUsername && StringUtils.isNullOrEmpty(username)) { throw new IllegalArgumentException("Username must not be null or empty");