From 4d1eaf522a11f84db9c6e454ac295116fd9a4dc7 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 12 Jul 2013 22:54:03 +0000 Subject: [PATCH] SMACK-450 Make VCard.doLoad() return if the received packet was not an error and also not an VCard. Avoid calling VCard.load() with 'null' as argument. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_1@13713 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smackx/packet/VCard.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/source/org/jivesoftware/smackx/packet/VCard.java b/source/org/jivesoftware/smackx/packet/VCard.java index 70d2d59fa..c9aa65856 100644 --- a/source/org/jivesoftware/smackx/packet/VCard.java +++ b/source/org/jivesoftware/smackx/packet/VCard.java @@ -568,20 +568,22 @@ public class VCard extends IQ { connection.sendPacket(this); VCard result = null; - try { - result = (VCard) collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); + Packet packet = collector.nextResult(SmackConfiguration.getPacketReplyTimeout()); - if (result == null) { - String errorMessage = "Timeout getting VCard information"; - throw new XMPPException(errorMessage, new XMPPError( - XMPPError.Condition.request_timeout, errorMessage)); - } - if (result.getError() != null) { - throw new XMPPException(result.getError()); - } + if (packet == null) { + String errorMessage = "Timeout getting VCard information"; + throw new XMPPException(errorMessage, new XMPPError(XMPPError.Condition.request_timeout, errorMessage)); + } + if (packet.getError() != null) { + throw new XMPPException(packet.getError()); + } + + try { + result = (VCard) packet; } catch (ClassCastException e) { System.out.println("No VCard for " + user); + return; } copyFieldsFrom(result);