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
1 changed files with 4 additions and 4 deletions

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