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
This commit is contained in:
Florian Schmaus 2013-07-12 22:54:03 +00:00 committed by flow
parent d237e06dab
commit 4d1eaf522a
1 changed files with 12 additions and 10 deletions

View File

@ -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);