diff --git a/source/org/jivesoftware/smack/PacketReader.java b/source/org/jivesoftware/smack/PacketReader.java index 148ed77ae..c1af2723d 100644 --- a/source/org/jivesoftware/smack/PacketReader.java +++ b/source/org/jivesoftware/smack/PacketReader.java @@ -288,16 +288,14 @@ class PacketReader { // Get the connection id. for (int i=0; i + * + * 1) An opening stream was sent from a non XMPP 1.0 compliant server + * 2) Stream features were received from an XMPP 1.0 compliant server that does not support TLS + * 3) TLS negotiation was successful + * + */ + private void releaseConnectionIDLock() { + synchronized(connectionIDLock) { + connectionIDLock.notifyAll(); + } + } + /** * Processes a packet after it's been fully parsed by looping through the installed * packet collectors and listeners and letting them examine the packet to see if @@ -390,17 +403,19 @@ class PacketReader { } private void parseFeatures(XmlPullParser parser) throws Exception { - boolean done = false; + boolean startTLSReceived = false; + boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("starttls")) { + startTLSReceived = true; // Confirm the server that we want to use TLS connection.startTLSReceived(); } - else if (parser.getName().equals("mechanisms") && connection.isUsingTLS()) { - // The server is reporting available SASL mechanism. Store this information + else if (parser.getName().equals("mechanisms")) { + // The server is reporting available SASL mechanisms. Store this information // which will be used later while logging (i.e. authenticating) into // the server connection.getSASLAuthentication() @@ -421,6 +436,9 @@ class PacketReader { } } } + if (!startTLSReceived) { + releaseConnectionIDLock(); + } } /**