From bc093b620df06ade8783c1a5f3b57ed7778a8d44 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 13 Mar 2015 09:27:18 +0100 Subject: [PATCH] Make Provider.parse() just throw Exception instead of throwing XmlPullParserException, IOException and SmackException. Add a guard to AbstractXMPPConnection.processPacket() to always re-throw RuntimeExceptions. --- .../smack/AbstractXMPPConnection.java | 8 ++- .../provider/EmbeddedExtensionProvider.java | 6 +- .../jivesoftware/smack/provider/Provider.java | 8 +-- .../smack/util/PacketParserUtils.java | 58 +++++++------------ .../smack/test/util/TestUtils.java | 5 +- .../provider/CarbonManagerProvider.java | 5 +- .../AbstractHttpOverXmppProvider.java | 7 +-- .../provider/HttpOverXmppReqProvider.java | 6 +- .../provider/HttpOverXmppRespProvider.java | 6 +- .../ibb/provider/DataPacketProvider.java | 4 +- .../provider/AdHocCommandDataProvider.java | 6 +- .../disco/provider/DiscoverInfoProvider.java | 6 +- .../forward/provider/ForwardedProvider.java | 4 +- .../provider/RegistrationProvider.java | 5 +- .../smackx/muc/provider/MUCOwnerProvider.java | 6 +- .../smackx/pep/provider/PEPProvider.java | 2 +- .../smackx/pubsub/provider/ItemProvider.java | 6 +- .../pubsub/provider/PubSubProvider.java | 6 +- .../smackx/search/UserSearch.java | 8 +-- .../si/provider/StreamInitiationProvider.java | 5 +- .../xdata/provider/DataFormProvider.java | 5 +- .../provider/CapsExtensionProviderTest.java | 6 +- .../smackx/xdata/packet/DataFormTest.java | 12 ++-- .../xdatalayout/packet/DataLayoutTest.java | 4 +- .../jingleold/provider/JingleProvider.java | 2 +- .../workgroup/ext/forms/WorkgroupForm.java | 7 +-- .../packet/OfferRequestProvider.java | 5 +- .../workgroup/packet/TranscriptProvider.java | 5 +- .../workgroup/packet/TranscriptSearch.java | 6 +- 29 files changed, 63 insertions(+), 156 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index cc8de36da..7d70d8f43 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -85,7 +85,6 @@ import org.jxmpp.jid.FullJid; import org.jxmpp.jid.Jid; import org.jxmpp.util.XmppStringUtils; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; public abstract class AbstractXMPPConnection implements XMPPConnection { @@ -960,6 +959,10 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { stanza = PacketParserUtils.parseStanza(parser); } catch (Exception e) { + // Always re-throw runtime exceptions, they are fatal + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } CharSequence content = PacketParserUtils.parseContentDepth(parser, parserDepth); UnparsablePacket message = new UnparsablePacket(content, e); @@ -1315,8 +1318,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { } } - protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException, - IOException, SmackException, InterruptedException { + protected final void parseFeatures(XmlPullParser parser) throws Exception { streamFeatures.clear(); final int initialDepth = parser.getDepth(); while (true) { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java index 0ecb625b2..6b2777c1b 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java @@ -16,17 +16,14 @@ */ package org.jivesoftware.smack.provider; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * @@ -84,8 +81,7 @@ import org.xmlpull.v1.XmlPullParserException; public abstract class EmbeddedExtensionProvider extends ExtensionElementProvider { @Override - public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, - SmackException { + public final PE parse(XmlPullParser parser, int initialDepth) throws Exception { final String namespace = parser.getNamespace(); final String name = parser.getName(); final int attributeCount = parser.getAttributeCount(); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java index 1ba343466..7b4a659eb 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java @@ -17,17 +17,13 @@ package org.jivesoftware.smack.provider; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.util.ParserUtils; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; public abstract class Provider { - public final E parse(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { + public final E parse(XmlPullParser parser) throws Exception{ // XPP3 calling convention assert: Parser should be at start tag ParserUtils.assertAtStartTag(parser); @@ -39,5 +35,5 @@ public abstract class Provider { return e; } - public abstract E parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException; + public abstract E parse(XmlPullParser parser, int initialDepth) throws Exception; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index 70e130147..a9ad69295 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -129,7 +129,7 @@ public class PacketParserUtils { return parser; } - public static Stanza parseStanza(String stanza) throws XmlPullParserException, IOException, SmackException { + public static Stanza parseStanza(String stanza) throws Exception { return parseStanza(getParserFor(stanza)); } @@ -140,11 +140,9 @@ public class PacketParserUtils { * * @param parser * @return a packet which is either a Message, IQ or Presence. - * @throws XmlPullParserException - * @throws SmackException - * @throws IOException + * @throws Exception */ - public static Stanza parseStanza(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { + public static Stanza parseStanza(XmlPullParser parser) throws Exception { ParserUtils.assertAtStartTag(parser); final String name = parser.getName(); switch (name) { @@ -211,12 +209,10 @@ public class PacketParserUtils { * * @param parser the XML parser, positioned at the start of a message packet. * @return a Message packet. - * @throws IOException - * @throws XmlPullParserException - * @throws SmackException + * @throws Exception */ public static Message parseMessage(XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { ParserUtils.assertAtStartTag(parser); assert(parser.getName().equals(Message.ELEMENT)); @@ -513,12 +509,10 @@ public class PacketParserUtils { * * @param parser the XML parser, positioned at the start of a presence packet. * @return a Presence packet. - * @throws IOException - * @throws XmlPullParserException - * @throws SmackException + * @throws Exception */ public static Presence parsePresence(XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); @@ -600,7 +594,7 @@ public class PacketParserUtils { * @throws IOException * @throws SmackException */ - public static IQ parseIQ(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { + public static IQ parseIQ(XmlPullParser parser) throws Exception { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); IQ iqPacket = null; @@ -792,11 +786,9 @@ public class PacketParserUtils { * * @param parser the XML parser. * @return an stream error packet. - * @throws XmlPullParserException if an exception occurs while parsing the packet. - * @throws SmackException + * @throws Exception if an exception occurs while parsing the packet. */ - public static StreamError parseStreamError(XmlPullParser parser) throws IOException, XmlPullParserException, - SmackException { + public static StreamError parseStreamError(XmlPullParser parser) throws Exception { final int initialDepth = parser.getDepth(); List extensions = new ArrayList(); Map descriptiveTexts = null; @@ -844,12 +836,10 @@ public class PacketParserUtils { * * @param parser the XML parser. * @return an error sub-packet. - * @throws IOException - * @throws XmlPullParserException - * @throws SmackException + * @throws Exception */ public static XMPPError parseError(XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { final int initialDepth = parser.getDepth(); Map descriptiveTexts = null; XMPPError.Condition condition = null; @@ -898,8 +888,7 @@ public class PacketParserUtils { */ @Deprecated public static ExtensionElement parsePacketExtension(String elementName, String namespace, - XmlPullParser parser) throws XmlPullParserException, - IOException, SmackException { + XmlPullParser parser) throws Exception { return parseExtensionElement(elementName, namespace, parser); } @@ -912,8 +901,7 @@ public class PacketParserUtils { * @return an extension element. */ public static ExtensionElement parseExtensionElement(String elementName, String namespace, - XmlPullParser parser) throws XmlPullParserException, - IOException, SmackException { + XmlPullParser parser) throws Exception { ParserUtils.assertAtStartTag(parser); // See if a provider is registered to handle the extension. ExtensionElementProvider provider = ProviderManager.getExtensionProvider(elementName, namespace); @@ -1017,51 +1005,49 @@ public class PacketParserUtils { } @Deprecated - public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws XmlPullParserException, - IOException, SmackException { + public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws Exception { addExtensionElement(packet, parser); } @Deprecated public static void addPacketExtension(Stanza packet, XmlPullParser parser, String elementName, String namespace) - throws XmlPullParserException, IOException, SmackException { + throws Exception { addExtensionElement(packet, parser, elementName, namespace); } @Deprecated public static void addPacketExtension(Collection collection, XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { addExtensionElement(collection, parser, parser.getName(), parser.getNamespace()); } @Deprecated public static void addPacketExtension(Collection collection, XmlPullParser parser, - String elementName, String namespace) throws XmlPullParserException, IOException, SmackException { + String elementName, String namespace) throws Exception { addExtensionElement(collection, parser, elementName, namespace); } public static void addExtensionElement(Stanza packet, XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { ParserUtils.assertAtStartTag(parser); addExtensionElement(packet, parser, parser.getName(), parser.getNamespace()); } public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName, - String namespace) throws XmlPullParserException, IOException, SmackException { + String namespace) throws Exception{ ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); packet.addExtension(packetExtension); } public static void addExtensionElement(Collection collection, - XmlPullParser parser) throws XmlPullParserException, IOException, - SmackException { + XmlPullParser parser) throws Exception { addExtensionElement(collection, parser, parser.getName(), parser.getNamespace()); } public static void addExtensionElement(Collection collection, XmlPullParser parser, String elementName, String namespace) - throws XmlPullParserException, IOException, SmackException { + throws Exception { ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); collection.add(packetExtension); } diff --git a/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java b/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java index c1c03bf00..fd687a95c 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.ParserUtils; @@ -79,13 +78,13 @@ final public class TestUtils { } public static EE parseExtensionElement(String elementString) - throws XmlPullParserException, IOException, SmackException { + throws Exception { return parseExtensionElement(getParser(elementString)); } @SuppressWarnings("unchecked") public static EE parseExtensionElement(XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { ParserUtils.assertAtStartTag(parser); final String elementName = parser.getName(); final String namespace = parser.getNamespace(); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java index 65c90ef63..b3c24a8f2 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java @@ -16,8 +16,6 @@ */ package org.jivesoftware.smackx.carbons.provider; -import java.io.IOException; - import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.carbons.packet.CarbonExtension; @@ -25,7 +23,6 @@ import org.jivesoftware.smackx.carbons.packet.CarbonExtension.Direction; import org.jivesoftware.smackx.forward.packet.Forwarded; import org.jivesoftware.smackx.forward.provider.ForwardedProvider; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * This class implements the {@link ExtensionElementProvider} to parse @@ -40,7 +37,7 @@ public class CarbonManagerProvider extends ExtensionElementProvider { @Override public AdHocCommandData parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { boolean done = false; AdHocCommandData adHocCommandData = new AdHocCommandData(); DataFormProvider dataFormProvider = new DataFormProvider(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java index 40f9587d3..577041633 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java @@ -17,14 +17,10 @@ package org.jivesoftware.smackx.disco.provider; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * The DiscoverInfoProvider parses Service Discovery information packets. @@ -35,7 +31,7 @@ public class DiscoverInfoProvider extends IQProvider { @Override public DiscoverInfo parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { DiscoverInfo discoverInfo = new DiscoverInfo(); boolean done = false; DiscoverInfo.Identity identity = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java index 0a2b3a237..fdd0fcc6f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java @@ -16,7 +16,6 @@ */ package org.jivesoftware.smackx.forward.provider; -import java.io.IOException; import java.util.logging.Logger; import org.jivesoftware.smack.SmackException; @@ -28,7 +27,6 @@ import org.jivesoftware.smackx.delay.packet.DelayInformation; import org.jivesoftware.smackx.delay.provider.DelayInformationProvider; import org.jivesoftware.smackx.forward.packet.Forwarded; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * This class implements the {@link ExtensionElementProvider} to parse @@ -41,7 +39,7 @@ public class ForwardedProvider extends ExtensionElementProvider { private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName()); @Override - public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { + public Forwarded parse(XmlPullParser parser, int initialDepth) throws Exception { DelayInformation di = null; Stanza packet = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java index 9bdf5f7b6..bf3aa34e0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java @@ -16,26 +16,23 @@ */ package org.jivesoftware.smackx.iqregister.provider; -import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.iqregister.packet.Registration; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; public class RegistrationProvider extends IQProvider { @Override public Registration parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { String instruction = null; Map fields = new HashMap(); List packetExtensions = new LinkedList(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java index 9b476b1ad..d565dd582 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java @@ -17,14 +17,10 @@ package org.jivesoftware.smackx.muc.provider; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.muc.packet.MUCOwner; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner) @@ -35,7 +31,7 @@ public class MUCOwnerProvider extends IQProvider { @Override public MUCOwner parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { MUCOwner mucOwner = new MUCOwner(); boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java index 8786bb26f..cc10a6514 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pep/provider/PEPProvider.java @@ -61,7 +61,7 @@ public class PEPProvider extends ExtensionElementProvider { */ @Override public ExtensionElement parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { ExtensionElement pepItem = null; boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java index 490d104b2..971737f77 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java @@ -16,9 +16,6 @@ */ package org.jivesoftware.smackx.pubsub.provider; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ProviderManager; @@ -28,7 +25,6 @@ import org.jivesoftware.smackx.pubsub.PayloadItem; import org.jivesoftware.smackx.pubsub.SimplePayload; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * Parses an item element as is defined in both the {@link PubSubNamespace#BASIC} and @@ -42,7 +38,7 @@ public class ItemProvider extends ExtensionElementProvider { @Override public Item parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { String id = parser.getAttributeValue(null, "id"); String node = parser.getAttributeValue(null, "node"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java index 48730b8be..1cbe3e600 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java @@ -16,16 +16,12 @@ */ package org.jivesoftware.smackx.pubsub.provider; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smackx.pubsub.packet.PubSub; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * Parses the root pubsub packet extensions of the {@link IQ} packet and returns @@ -37,7 +33,7 @@ public class PubSubProvider extends IQProvider { @Override public PubSub parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { String namespace = parser.getNamespace(); PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace); PubSub pubsub = new PubSub(pubSubNamespace); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java index aee851516..4df17e8f3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java @@ -16,9 +16,6 @@ */ package org.jivesoftware.smackx.search; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.XMPPConnection; @@ -32,7 +29,6 @@ import org.jivesoftware.smackx.xdata.FormField; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jxmpp.jid.DomainBareJid; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * Implements the protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol @@ -127,7 +123,7 @@ public class UserSearch extends SimpleIQ { // FIXME this provider does return two different types of IQs @Override - public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { + public IQ parse(XmlPullParser parser, int initialDepth) throws Exception { UserSearch search = null; SimpleUserSearch simpleUserSearch = new SimpleUserSearch(); @@ -163,7 +159,7 @@ public class UserSearch extends SimpleIQ { private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) - throws XmlPullParserException, IOException, SmackException { + throws Exception { DataForm dataForm = new DataForm(DataForm.Type.form); boolean done = false; dataForm.setTitle("User Search"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java index b26af9e84..85495ee0f 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java @@ -16,13 +16,11 @@ */ package org.jivesoftware.smackx.si.provider; -import java.io.IOException; import java.text.ParseException; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jxmpp.util.XmppDateTime; import org.jivesoftware.smackx.si.packet.StreamInitiation; @@ -30,7 +28,6 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation.File; import org.jivesoftware.smackx.xdata.packet.DataForm; import org.jivesoftware.smackx.xdata.provider.DataFormProvider; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * The StreamInitiationProvider parses StreamInitiation packets. @@ -43,7 +40,7 @@ public class StreamInitiationProvider extends IQProvider { @Override public StreamInitiation parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { boolean done = false; // si diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java index 3c44e3b8e..1c84c3cda 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java @@ -17,7 +17,6 @@ package org.jivesoftware.smackx.xdata.provider; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.roster.packet.RosterPacket; import org.jivesoftware.smack.roster.provider.RosterPacketProvider; @@ -42,8 +41,8 @@ import java.util.List; public class DataFormProvider extends ExtensionElementProvider { @Override - public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, - SmackException { + public DataForm parse(XmlPullParser parser, int initialDepth) throws + Exception { DataForm.Type dataFormType = DataForm.Type.fromString(parser.getAttributeValue("", "type")); DataForm dataForm = new DataForm(dataFormType); outerloop: while (true) { diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java index 88e8afa98..6d8ac15a1 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/caps/provider/CapsExtensionProviderTest.java @@ -18,19 +18,15 @@ package org.jivesoftware.smackx.caps.provider; import static org.junit.Assert.assertNotNull; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.test.util.TestUtils; import org.jivesoftware.smackx.InitExtensions; import org.jivesoftware.smackx.caps.packet.CapsExtension; import org.junit.Test; -import org.xmlpull.v1.XmlPullParserException; public class CapsExtensionProviderTest extends InitExtensions { @Test - public void parseTest() throws XmlPullParserException, IOException, SmackException { + public void parseTest() throws Exception { // @formatter:off final String capsExtensionString = " { */ @Override public Jingle parse(XmlPullParser parser, int intialDepth) - throws XmlPullParserException, IOException, SmackException { + throws Exception { Jingle jingle = new Jingle(); String sid = ""; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java index 29c585151..d856dbabd 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java @@ -17,14 +17,10 @@ package org.jivesoftware.smackx.workgroup.ext.forms; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.SimpleIQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; public class WorkgroupForm extends SimpleIQ { @@ -51,8 +47,7 @@ public class WorkgroupForm extends SimpleIQ { @Override public WorkgroupForm parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, - SmackException { + throws Exception { WorkgroupForm answer = new WorkgroupForm(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java index 2429f2aea..0f99ad1e4 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java @@ -23,16 +23,13 @@ import org.jivesoftware.smackx.workgroup.agent.OfferContent; import org.jivesoftware.smackx.workgroup.agent.TransferRequest; import org.jivesoftware.smackx.workgroup.agent.UserRequest; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.ParserUtils; import org.jxmpp.jid.Jid; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,7 +46,7 @@ public class OfferRequestProvider extends IQProvider { // happen anytime soon. @Override - public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { + public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws Exception { int eventType = parser.getEventType(); String sessionID = null; int timeout = -1; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java index 4af4cf70b..807ba2973 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java @@ -17,14 +17,11 @@ package org.jivesoftware.smackx.workgroup.packet; -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -36,7 +33,7 @@ import java.util.List; public class TranscriptProvider extends IQProvider { @Override - public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { + public Transcript parse(XmlPullParser parser, int initialDepth) throws Exception { String sessionID = parser.getAttributeValue("", "sessionID"); List packets = new ArrayList(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java index 79fd4c2d1..377935891 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java @@ -17,14 +17,10 @@ package org.jivesoftware.smackx.workgroup.packet; -import java.io.IOException; - -import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.packet.SimpleIQ; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; /** * IQ packet for retrieving the transcript search form, submiting the completed search form @@ -56,7 +52,7 @@ public class TranscriptSearch extends SimpleIQ { public static class Provider extends IQProvider { @Override - public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { + public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws Exception { TranscriptSearch answer = new TranscriptSearch(); boolean done = false;