Prevent deadlock if a XMPP certificate validation fails

cusax-fix 4997
Ingo Bauersachs 12 years ago
parent 0b566e6a78
commit feadc3e4cc

@ -962,10 +962,14 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
ssContactList.cleanup();
subscribtionPacketListener = null;
if(parentProvider.getConnection() != null &&
parentProvider.getConnection().getRoster() != null)
parentProvider.getConnection().getRoster()
XMPPConnection connection = parentProvider.getConnection();
if(connection != null)
{
// the roster is guaranteed to be non-null
connection.getRoster()
.removeRosterListener(contactChangesListener);
}
contactChangesListener = null;
}
}

@ -2433,10 +2433,19 @@ public void checkServerTrusted(X509Certificate[] chain, String authType)
}
catch(CertificateException e)
{
fireRegistrationStateChanged(getRegistrationState(),
// notify in a separate thread to avoid a deadlock when a
// reg state listener accesses a synchronized XMPPConnection
// method (like getRoster)
new Thread(new Runnable()
{
public void run()
{
fireRegistrationStateChanged(getRegistrationState(),
RegistrationState.UNREGISTERED,
RegistrationStateChangeEvent.REASON_USER_REQUEST,
"Not trusted certificate");
}
}).start();
throw e;
}

Loading…
Cancel
Save