From fc3ec2ab8a3cd094c13d6fb454d0694492fd4b9b Mon Sep 17 00:00:00 2001 From: rcollier Date: Tue, 30 Oct 2012 01:53:44 +0000 Subject: [PATCH] SMACK-390 Log exception in parsing extensions of Presence. Valid Presence will still be returned with extensions missing. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13326 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smack/util/PacketParserUtils.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/source/org/jivesoftware/smack/util/PacketParserUtils.java b/source/org/jivesoftware/smack/util/PacketParserUtils.java index 0c3f9db50..14d5d47ab 100644 --- a/source/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/source/org/jivesoftware/smack/util/PacketParserUtils.java @@ -20,15 +20,6 @@ package org.jivesoftware.smack.util; -import org.jivesoftware.smack.Connection; -import org.jivesoftware.smack.packet.*; -import org.jivesoftware.smack.provider.IQProvider; -import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.jivesoftware.smack.provider.ProviderManager; -import org.jivesoftware.smack.sasl.SASLMechanism.Failure; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - import java.beans.PropertyDescriptor; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -39,6 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.jivesoftware.smack.Connection; +import org.jivesoftware.smack.packet.Authentication; +import org.jivesoftware.smack.packet.Bind; +import org.jivesoftware.smack.packet.DefaultPacketExtension; +import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.packet.Message; +import org.jivesoftware.smack.packet.Packet; +import org.jivesoftware.smack.packet.PacketExtension; +import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.packet.Registration; +import org.jivesoftware.smack.packet.RosterPacket; +import org.jivesoftware.smack.packet.StreamError; +import org.jivesoftware.smack.packet.XMPPError; +import org.jivesoftware.smack.provider.IQProvider; +import org.jivesoftware.smack.provider.PacketExtensionProvider; +import org.jivesoftware.smack.provider.ProviderManager; +import org.jivesoftware.smack.sasl.SASLMechanism.Failure; +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + /** * Utility class that helps to parse packets. Any parsing packets method that must be shared * between many clients must be placed in this utility class. @@ -245,8 +256,12 @@ public class PacketParserUtils { } // Otherwise, it must be a packet extension. else { - presence.addExtension( - PacketParserUtils.parsePacketExtension(elementName, namespace, parser)); + try { + presence.addExtension(PacketParserUtils.parsePacketExtension(elementName, namespace, parser)); + } + catch (Exception e) { + System.err.println("Failed to parse extension packet in Presence packet."); + } } } else if (eventType == XmlPullParser.END_TAG) {