} finally {
lock.unlock();
}
}
// Bind the resource
IQ iq = new IQ(IQ.Type.SET, new Bind(this.resource));
IQ result;
try {
result = query(iq);
} catch (StanzaException e) {
LoginException loginException = new LoginException("Error during resource binding: " + e.getStanza().toString());
loginException.initCause(e);
throw loginException;
} catch (XmppException e) {
LoginException loginException = new LoginException(e.getMessage());
loginException.initCause(e);
throw loginException;
}
Bind bindResult = result.getExtension(Bind.class);
this.connectedResource = bindResult.getJid();
// Deprecated method of session binding, according to the <a href="http://xmpp.org/rfcs/rfc3921.html#session">old specification</a>
// This is no longer used, according to the <a href="http://xmpp.org/rfcs/rfc6120.html">updated specification</a>.
// But some old server implementation still require it.
if (streamFeaturesManager.getFeatures().containsKey(Session.class)) {
try {
query(new IQ(IQ.Type.SET, new Session()));
} catch (StanzaException e) {
LoginException loginException = new LoginException("Error during session establishment: " + e.getStanza().toString());
loginException.initCause(e);
throw loginException;
} catch (XmppException e) {