From 36e0744c607174125c3f18f6d5a2e9c509baa662 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Tue, 25 Mar 2003 16:24:03 +0000 Subject: [PATCH] Fix for ClassCastException with bad username. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1858 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/XMPPConnection.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java index d657222cb..2a6865833 100644 --- a/source/org/jivesoftware/smack/XMPPConnection.java +++ b/source/org/jivesoftware/smack/XMPPConnection.java @@ -259,14 +259,17 @@ public class XMPPConnection { // Send the packet packetWriter.sendPacket(discoveryAuth); // Wait up to five seconds for a response from the server. - Authentication authTypes = (Authentication)collector.nextResult(5000); - collector.cancel(); - if (authTypes == null) { + IQ response = (IQ)collector.nextResult(5000); + if (response == null) { throw new XMPPException("No response from the server."); } - else if (authTypes.getType().equals(IQ.Type.ERROR)) { - throw new XMPPException(authTypes.getError()); + // If the server replied with an error, throw an exception. + else if (response.getType() == IQ.Type.ERROR) { + throw new XMPPException(response.getError()); } + // Otherwise, no error so continue processing. + Authentication authTypes = (Authentication)response; + collector.cancel(); // Now, create the authentication packet we'll send to the server. Authentication auth = new Authentication(); @@ -290,7 +293,7 @@ public class XMPPConnection { // Send the packet. packetWriter.sendPacket(auth); // Wait up to five seconds for a response from the server. - IQ response = (IQ)collector.nextResult(5000); + response = (IQ)collector.nextResult(5000); if (response == null) { throw new XMPPException("Authentication failed."); }