1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

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.
This commit is contained in:
Florian Schmaus 2015-01-18 11:16:12 +01:00
parent 4c218c96f6
commit 0bcd3d9356

View file

@ -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");