Bump ErrorProne to 2.5.1 and refactor Providers a bit

This also resulted in a refactoring of the Providers and parsing
Exceptions. NumberFormatException and ParseException can now be thrown
directly, the wrapping in a SmackParsingException is down at a higher
layer, i.e. in AbstractProvider.
master
Florian Schmaus 2 years ago
parent 1df0763f92
commit a7b3303f3e
  1. 6
      build.gradle
  2. 7
      smack-android-extensions/src/main/java/org/jivesoftware/smackx/ping/android/ServerPingWithAlarmManager.java
  3. 1
      smack-core/src/main/java/org/jivesoftware/smack/SASLAuthentication.java
  4. 2
      smack-core/src/main/java/org/jivesoftware/smack/StanzaCollector.java
  5. 20
      smack-core/src/main/java/org/jivesoftware/smack/c2s/ModularXmppClientToServerConnection.java
  6. 1
      smack-core/src/main/java/org/jivesoftware/smack/filter/IQTypeFilter.java
  7. 1
      smack-core/src/main/java/org/jivesoftware/smack/filter/MessageTypeFilter.java
  8. 3
      smack-core/src/main/java/org/jivesoftware/smack/filter/PresenceTypeFilter.java
  9. 9
      smack-core/src/main/java/org/jivesoftware/smack/iqrequest/AbstractIqRequestHandler.java
  10. 14
      smack-core/src/main/java/org/jivesoftware/smack/parsing/SmackParsingException.java
  11. 51
      smack-core/src/main/java/org/jivesoftware/smack/provider/AbstractProvider.java
  12. 8
      smack-core/src/main/java/org/jivesoftware/smack/provider/IQProvider.java
  13. 4
      smack-core/src/main/java/org/jivesoftware/smack/provider/IntrospectionProvider.java
  14. 9
      smack-core/src/main/java/org/jivesoftware/smack/provider/IqProvider.java
  15. 8
      smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java
  16. 6
      smack-core/src/main/java/org/jivesoftware/smack/sasl/core/ScramMechanism.java
  17. 7
      smack-core/src/main/java/org/jivesoftware/smack/util/MultiMap.java
  18. 24
      smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java
  19. 2
      smack-core/src/main/java/org/jivesoftware/smack/util/stringencoder/Base32.java
  20. 2
      smack-core/src/test/java/org/jivesoftware/smack/ConnectionConfigurationTest.java
  21. 7
      smack-core/src/test/java/org/jivesoftware/smack/packet/XMPPErrorTest.java
  22. 70
      smack-core/src/test/java/org/jivesoftware/smack/provider/AbstractProviderTest.java
  23. 3
      smack-core/src/testFixtures/java/org/jivesoftware/smack/ThreadedDummyConnection.java
  24. 8
      smack-core/src/testFixtures/java/org/jivesoftware/smack/test/util/SmackTestUtil.java
  25. 6
      smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java
  26. 5
      smack-experimental/src/main/java/org/jivesoftware/smackx/dox/DnsOverXmppManager.java
  27. 3
      smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
  28. 5
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/IoTManager.java
  29. 11
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/Thing.java
  30. 19
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/data/provider/IoTFieldsExtensionProvider.java
  31. 5
      smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java
  32. 6
      smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java
  33. 6
      smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamResultProvider.java
  34. 3
      smack-experimental/src/main/java/org/jivesoftware/smackx/message_retraction/provider/RetractedElementProvider.java
  35. 11
      smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
  36. 4
      smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/provider/MUCLightBlockingIQProvider.java
  37. 3
      smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
  38. 5
      smack-experimental/src/main/java/org/jivesoftware/smackx/stanza_content_encryption/provider/ContentElementProvider.java
  39. 3
      smack-experimental/src/test/java/org/jivesoftware/smackx/mam/MamFinProviderTest.java
  40. 5
      smack-experimental/src/test/java/org/jivesoftware/smackx/mam/MamQueryIQProviderTest.java
  41. 5
      smack-experimental/src/test/java/org/jivesoftware/smackx/mam/QueryArchiveTest.java
  42. 9
      smack-experimental/src/test/java/org/jivesoftware/smackx/muclight/MUCLightBlockingTest.java
  43. 3
      smack-experimental/src/test/java/org/jivesoftware/smackx/stanza_content_encryption/provider/ContentElementProviderTest.java
  44. 3
      smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java
  45. 5
      smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/BlockingCommandManager.java
  46. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/blocking/provider/BlockListIQProvider.java
  47. 9
      smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java
  48. 14
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java
  49. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/InitiationListener.java
  50. 10
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamManager.java
  51. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5BytestreamRequest.java
  52. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/caps/EntityCapsManager.java
  53. 12
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java
  54. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java
  55. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/DelayInformationProvider.java
  56. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/LegacyDelayInformationProvider.java
  57. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferManager.java
  58. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
  59. 3
      smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java
  60. 11
      smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java
  61. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/geoloc/provider/GeoLocationProvider.java
  62. 3
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqlast/LastActivityManager.java
  63. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/AccountManager.java
  64. 5
      smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/JingleManager.java
  65. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/element/JingleReason.java
  66. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentDescriptionProvider.java
  67. 1
      smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/provider/JivePropertiesExtensionProvider.java
  68. 13
      smack-extensions/src/main/java/org/jivesoftware/smackx/last_interaction/provider/IdleProvider.java
  69. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
  70. 3
      smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java
  71. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetActiveListFilter.java
  72. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/filter/SetDefaultListFilter.java
  73. 20
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java
  74. 24
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java
  75. 17
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
  76. 3
      smack-extensions/src/main/java/org/jivesoftware/smackx/softwareinfo/form/SoftwareInfoForm.java
  77. 5
      smack-extensions/src/main/java/org/jivesoftware/smackx/time/EntityTimeManager.java
  78. 13
      smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java
  79. 3
      smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java
  80. 5
      smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FilledForm.java
  81. 7
      smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/Form.java
  82. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/xdatavalidation/packet/ValidateElement.java
  83. 3
      smack-extensions/src/test/java/org/jivesoftware/smackx/blocking/GetBlockingListTest.java
  84. 6
      smack-extensions/src/test/java/org/jivesoftware/smackx/bob/BoBIQTest.java
  85. 2
      smack-extensions/src/test/java/org/jivesoftware/smackx/ping/PingTest.java
  86. 5
      smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/AffiliationsExtensionTest.java
  87. 3
      smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java
  88. 6
      smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/PubSubNodeTest.java
  89. 7
      smack-extensions/src/test/java/org/jivesoftware/smackx/softwareinfo/SoftwareInfoFormTest.java
  90. 3
      smack-extensions/src/test/java/org/jivesoftware/smackx/softwareinfo/SoftwareInfoManagerTest.java
  91. 3
      smack-extensions/src/test/java/org/jivesoftware/smackx/xdata/packet/DataFormTest.java
  92. 3
      smack-extensions/src/test/java/org/jivesoftware/smackx/xdatavalidation/provider/DataValidationTest.java
  93. 3
      smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java
  94. 22
      smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
  95. 3
      smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java
  96. 15
      smack-im/src/test/java/org/jivesoftware/smack/chat/ChatConnectionTest.java
  97. 13
      smack-im/src/test/java/org/jivesoftware/smack/roster/RosterTest.java
  98. 7
      smack-im/src/test/java/org/jivesoftware/smack/roster/RosterVersioningTest.java
  99. 5
      smack-im/src/test/java/org/jivesoftware/smack/roster/SubscriptionPreApprovalTest.java
  100. 4
      smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -12,7 +12,7 @@ buildscript {
plugins {
id 'ru.vyarus.animalsniffer' version '1.5.0'
id 'net.ltgt.errorprone' version '1.1.1'
id 'net.ltgt.errorprone' version '1.3.0'
// Use e.g. "gradle <task> taskTree" to show its dependency tree.
id 'com.dorongold.task-tree' version '1.5'
id 'com.github.kt3k.coveralls' version '2.10.2'
@ -218,6 +218,8 @@ allprojects {
// Disabled but should be re-enabled at some point
//'-Xep:InconsistentCapitalization:OFF',
'-Xep:MixedMutabilityReturnType:OFF',
// TODO: Re-enable once Smack's minimum Android SDK level is 26 or higher.
'-Xep:JavaUtilDate:OFF',
]
}
}
@ -293,7 +295,7 @@ tasks.withType(Javadoc) {
testImplementation 'org.mockito:mockito-inline:3.3.3'
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
errorprone 'com.google.errorprone:error_prone_core:2.3.4'
errorprone 'com.google.errorprone:error_prone_core:2.5.1'
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
}

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2017 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.ping.android;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.logging.Logger;
@ -113,14 +112,14 @@ public final class ServerPingWithAlarmManager extends Manager {
@Override
public void onReceive(Context context, Intent intent) {
LOGGER.fine("Ping Alarm broadcast received");
Set<Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
Set<Map.Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
synchronized (ServerPingWithAlarmManager.class) {
// Make a copy to avoid ConcurrentModificationException when
// iterating directly over INSTANCES and the Set is modified
// concurrently by creating a new ServerPingWithAlarmManager.
managers = new HashSet<>(INSTANCES.entrySet());
}
for (Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
for (Map.Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
XMPPConnection connection = entry.getKey();
if (entry.getValue().isEnabled()) {
LOGGER.fine("Calling pingServerIfNecessary for connection "

@ -249,7 +249,6 @@ public final class SASLAuthentication {
* Notification message saying that SASL authentication was successful. The next step
* would be to bind the resource.
* @param success result of the authentication.
* @throws SmackException if Smack detected an exceptional situation.
* @throws InterruptedException if the calling thread was interrupted.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws SmackSaslException if a SASL specific error occurred.

@ -343,7 +343,7 @@ public final class StanzaCollector implements AutoCloseable {
*
* @param packet the stanza to process.
*/
protected void processStanza(Stanza packet) {
void processStanza(Stanza packet) {
if (packetFilter == null || packetFilter.accept(packet)) {
synchronized (this) {
if (resultQueue.size() == maxQueueSize) {

@ -99,7 +99,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
private boolean featuresReceived;
protected boolean streamResumed;
private boolean streamResumed;
private GraphVertex<State> currentStateVertex;
@ -264,7 +264,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
walkStateGraph(walkStateGraphContext);
}
protected WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
private WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
return WalkStateGraphContext.builder(currentStateVertex.getElement().getStateDescriptor().getClass(), finalStateClass);
}
@ -279,7 +279,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
revertedState.resetState();
}
protected void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
private void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
throws XMPPException, IOException, SmackException, InterruptedException {
// Save a copy of the current state
GraphVertex<State> previousStateVertex = currentStateVertex;
@ -491,7 +491,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
}
}
protected SSLSession getSSLSession() {
private SSLSession getSSLSession() {
final XmppClientToServerTransport transport = activeTransport;
if (transport == null) {
return null;
@ -505,7 +505,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
notifyWaitingThreads();
}
protected void parseAndProcessElement(String element) {
private void parseAndProcessElement(String element) {
try {
XmlPullParser parser = PacketParserUtils.getParserFor(element);
@ -556,11 +556,11 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
}
}
protected synchronized void prepareToWaitForFeaturesReceived() {
private synchronized void prepareToWaitForFeaturesReceived() {
featuresReceived = false;
}
protected void waitForFeaturesReceived(String waitFor)
private void waitForFeaturesReceived(String waitFor)
throws InterruptedException, SmackException, XMPPException {
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
}
@ -571,7 +571,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
}
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
private void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
SmackException, XMPPException {
prepareToWaitForFeaturesReceived();
@ -1028,7 +1028,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
return connectionStateMachineListeners.remove(connectionStateMachineListener);
}
protected void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
private void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
if (connectionStateMachineListeners.isEmpty()) {
return;
}
@ -1056,7 +1056,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
walkStateGraph(walkStateGraphContext);
}
protected Map<String, Object> getFilterStats() {
private Map<String, Object> getFilterStats() {
Collection<XmppInputOutputFilter> filters;
synchronized (this) {
if (inputOutputFilters.isEmpty() && previousInputOutputFilters != null) {

@ -27,6 +27,7 @@ import org.jivesoftware.smack.util.Objects;
* @author Alexander Wenckus
*
*/
@SuppressWarnings("BadImport")
public final class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
public static final StanzaFilter GET = new IQTypeFilter(Type.get);

@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.Message.Type;
* @see org.jivesoftware.smack.packet.Message.Type
* @author Ward Harold
*/
@SuppressWarnings("BadImport")
public final class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> {
public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal);

@ -1,6 +1,6 @@
/**
*
* Copyright 2014 Florian Schmaus
* Copyright 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,6 +24,7 @@ import org.jivesoftware.smack.util.Objects;
* A filter for Presence types. Returns true only if the stanza is an Presence stanza and it matches the type provided in the
* constructor.
*/
@SuppressWarnings("BadImport")
public final class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> {
public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available);

@ -1,6 +1,6 @@
/**
*
* Copyright 2015 Florian Schmaus
* Copyright 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.jivesoftware.smack.iqrequest;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
/**
* Convenience class to create IQ requests handlers.
@ -26,10 +25,10 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
private final String element;
private final String namespace;
private final Type type;
private final IQ.Type type;
private final Mode mode;
protected AbstractIqRequestHandler(String element, String namespace, Type type, Mode mode) {
protected AbstractIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
switch (type) {
case set:
case get:
@ -52,7 +51,7 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
}
@Override
public Type getType() {
public IQ.Type getType() {
return type;
}

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2020 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,12 +34,24 @@ public class SmackParsingException extends Exception {
super(message);
}
/**
* Deprecated, do not import.
* @deprecated do not import.
*/
@Deprecated
// TODO: Remove in Smack 4.6.
public static class SmackTextParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Deprecated, do not use.
* @param parsingException the exception.
* @deprecated do not use, simply throw ParseException.
*/
@Deprecated
public SmackTextParseException(ParseException parsingException) {
super(parsingException);
}

@ -16,11 +16,15 @@
*/
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.xml.XmlPullParserException;
public class AbstractProvider<E extends Element> {
@ -55,4 +59,51 @@ public class AbstractProvider<E extends Element> {
public final Class<E> getElementClass() {
return elementClass;
}
public static final class TextParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
private final ParseException parseException;
private TextParseException(ParseException parseException) {
super(parseException);
this.parseException = parseException;
}
public ParseException getParseException() {
return parseException;
}
}
public static final class NumberFormatParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
private NumberFormatParseException(NumberFormatException numberFormatException) {
super(numberFormatException);
}
}
protected interface WrappableParser<E> {
E parse() throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}
protected static <E> E wrapExceptions(WrappableParser<E> parser)
throws XmlPullParserException, IOException, SmackParsingException {
E e;
try {
e = parser.parse();
} catch (ParseException parseException) {
throw new TextParseException(parseException);
} catch (NumberFormatException numberFormatException) {
throw new NumberFormatParseException(numberFormatException);
}
return e;
}
}

@ -18,6 +18,7 @@
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
@ -50,7 +51,7 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
I e = parse(parser, initialDepth, xmlEnvironment);
I e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
@ -59,11 +60,12 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
@Override
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
// Old-style IQ parsers do not need IqData.
return parse(parser, initialDepth, xmlEnvironment);
}
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -117,7 +117,7 @@ public class IntrospectionProvider{
* @param type the type of the property.
* @param value the encode String value to decode.
* @return the String value decoded into the specified type.
* @throws ClassNotFoundException
* @throws ClassNotFoundException if the provided class was not found.
*/
private static Object decode(Class<?> type, String value) throws ClassNotFoundException {
String name = type.getName();

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
@ -37,10 +38,12 @@ public abstract class IqProvider<I extends IQ> extends AbstractProvider<I> {
final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
return parse(parser, initialDepth, iqData, xmlEnvironment);
I i = wrapExceptions(() -> parse(parser, initialDepth, iqData, xmlEnvironment));
return i;
}
public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException;
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -50,12 +51,13 @@ public abstract class Provider<E extends Element> extends AbstractProvider<E> {
final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
E e = parse(parser, initialDepth, xmlEnvironment);
E e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return e;
}
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

@ -1,6 +1,6 @@
/**
*
* Copyright 2014-2020 Florian Schmaus
* Copyright 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +26,6 @@ import java.util.Random;
import javax.security.auth.callback.CallbackHandler;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.SmackSaslException;
import org.jivesoftware.smack.sasl.SASLMechanism;
import org.jivesoftware.smack.util.ByteUtils;
@ -263,6 +262,7 @@ public abstract class ScramMechanism extends SASLMechanism {
}
/**
* Get the channel binding data.
*
* @return the Channel Binding data.
* @throws SmackSaslException if a SASL specific error occurred.
@ -361,7 +361,7 @@ public abstract class ScramMechanism extends SASLMechanism {
* @param key TODO javadoc me please
* @param str TODO javadoc me please
* @return the HMAC-SHA1 value of the input.
* @throws SmackException if Smack detected an exceptional situation.
* @throws SmackSaslException if Smack detected an exceptional situation.
*/
private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException {
try {

@ -1,6 +1,6 @@
/**
*
* Copyright © 2015-2020 Florian Schmaus
* Copyright © 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
@ -251,7 +250,7 @@ public class MultiMap<K, V> {
public MultiMap<K, V> asUnmodifiableMultiMap() {
LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size());
for (Entry<K, List<V>> entry : map.entrySet()) {
for (Map.Entry<K, List<V>> entry : map.entrySet()) {
K key = entry.getKey();
List<V> values = entry.getValue();
@ -266,7 +265,7 @@ public class MultiMap<K, V> {
Map<K, List<V>> clonedMap = new LinkedHashMap<>(map.size());
// TODO: Use Map.forEach() once Smack's minimum Android API is 24 or higher.
for (Entry<K, List<V>> entry : map.entrySet()) {
for (Map.Entry<K, List<V>> entry : map.entrySet()) {
List<V> clonedList = CollectionUtil.newListWith(entry.getValue());
clonedMap.put(entry.getKey(), clonedList);
}

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,7 +30,6 @@ import org.jivesoftware.smack.datatypes.UInt32;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.RequiredAttributeMissingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
@ -308,30 +307,23 @@ public class ParserUtils {
return s;
}
public static Date getDateFromOptionalXep82String(String dateString) throws SmackTextParseException {
public static Date getDateFromOptionalXep82String(String dateString) throws ParseException {
if (dateString == null) {
return null;
}
return getDateFromXep82String(dateString);
}
public static Date getDateFromXep82String(String dateString) throws SmackTextParseException {
try {
return XmppDateTime.parseXEP0082Date(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
public static Date getDateFromXep82String(String dateString) throws ParseException {
return XmppDateTime.parseXEP0082Date(dateString);
}
public static Date getDateFromString(String dateString) throws SmackTextParseException {
try {
return XmppDateTime.parseDate(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
public static Date getDateFromString(String dateString) throws ParseException {
return XmppDateTime.parseDate(dateString);
}
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
public static Date getDateFromNextText(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
String dateString = parser.nextText();
return getDateFromString(dateString);
}

@ -104,6 +104,8 @@ public class Base32 {
for (int j = 0; j < blocklen; j++)
ds.writeByte((byte) (t[j] & 0xFF));
} catch (IOException e) {
// This should not happen.
throw new AssertionError(e);
}
}

@ -53,7 +53,7 @@ public class ConnectionConfigurationTest {
private static final class DummyConnectionConfiguration extends ConnectionConfiguration {
protected DummyConnectionConfiguration(Builder builder) {
DummyConnectionConfiguration(Builder builder) {
super(builder);
}

@ -20,17 +20,14 @@ import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.packet.StanzaError.Type;
import org.junit.Test;
public class XMPPErrorTest {
@Test
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException {
Map<Condition, Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
Map<StanzaError.Condition, StanzaError.Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum",
Condition.values().length,
StanzaError.Condition.values().length,
conditionToTypeMap.size());
}
}

@ -0,0 +1,70 @@
/**
*
* Copyright 2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smack.provider;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.junit.jupiter.api.Test;
public class AbstractProviderTest {
private static final ExtensionElementProvider<ExtensionElement> NUMBER_FORMAT_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
throw new NumberFormatException();
}
};
private static final String MESSAGE = "dummy message";
private static final int VALUE = 14768234;
private static final ExtensionElementProvider<ExtensionElement> PARSE_EXCEPTION_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
throw new ParseException(MESSAGE, VALUE);
}
};
@Test
public void testWrapsNumberFormatException() throws XmlPullParserException, IOException {
XmlPullParser parser = SmackTestUtil.createDummyParser();
assertThrows(AbstractProvider.NumberFormatParseException.class,
() -> NUMBER_FORMAT_THROWING_PROVIDER.parse(parser));
}
@Test
public void testWrapsParseException() throws XmlPullParserException, IOException {
XmlPullParser parser = SmackTestUtil.createDummyParser();
AbstractProvider.TextParseException testParseException = assertThrows(AbstractProvider.TextParseException.class,
() -> PARSE_EXCEPTION_THROWING_PROVIDER.parse(parser));
ParseException parseException = testParseException.getParseException();
assertEquals(MESSAGE, parseException.getMessage());
assertEquals(VALUE, parseException.getErrorOffset());
}
}

@ -24,7 +24,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
@ -58,7 +57,7 @@ public class ThreadedDummyConnection extends DummyConnection {
replyPacket.setStanzaId(packet.getStanzaId());
replyPacket.setTo(packet.getFrom());
if (replyPacket.getType() == null) {
replyPacket.setType(Type.result);
replyPacket.setType(IQ.Type.result);
}
new ProcessQueue(replyQ).start();

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,6 +30,7 @@ import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.Provider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParserFactory;
@ -125,6 +126,11 @@ public class SmackTestUtil {
return parser;
}
public static XmlPullParser createDummyParser() throws XmlPullParserException, IOException {
String dummyElement = "<empty-element/>";
return PacketParserUtils.getParserFor(dummyElement);
}
@SuppressWarnings("unchecked")
private static <E extends Element, P extends Provider<E>> P providerClassToProvider(Class<P> providerClass) {
P provider;

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus.
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.carbons.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
@Override
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Direction dir = Direction.valueOf(parser.getName());
Forwarded<Message> fwd = null;

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +31,6 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.packet.StanzaError.Type;
import org.jivesoftware.smack.util.RandomUtil;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -89,7 +88,7 @@ public final class DnsOverXmppManager extends Manager {
response = resolver.resolve(query);
} catch (IOException exception) {
StanzaError errorBuilder = StanzaError.getBuilder()
.setType(Type.CANCEL)
.setType(StanzaError.Type.CANCEL)
.setCondition(Condition.internal_server_error)
.setDescriptiveEnText("Exception while resolving your DNS query", exception)
.build()

@ -27,7 +27,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.WeakHashMap;
import java.util.logging.Level;
@ -437,7 +436,7 @@ public final class HttpFileUploadManager extends Manager {
urlConnection.setDoOutput(true);
urlConnection.setFixedLengthStreamingMode(fileSize);
urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
for (Entry<String, String> header : slot.getHeaders().entrySet()) {
for (Map.Entry<String, String> header : slot.getHeaders().entrySet()) {
urlConnection.setRequestProperty(header.getKey(), header.getValue());
}

@ -1,6 +1,6 @@
/**
*
* Copyright 2016 Florian Schmaus
* Copyright 2016-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
@ -70,7 +69,7 @@ public abstract class IoTManager extends Manager {
protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler {
protected IoTIqRequestHandler(String element, String namespace, Type type, Mode mode) {
protected IoTIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
super(element, namespace, type, mode);
}

@ -23,7 +23,6 @@ import java.util.Iterator;
import org.jivesoftware.smackx.iot.control.ThingControlRequest;
import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest;
import org.jivesoftware.smackx.iot.discovery.element.Tag;
import org.jivesoftware.smackx.iot.discovery.element.Tag.Type;
import org.jivesoftware.smackx.iot.element.NodeInfo;
public final class Thing {
@ -112,35 +111,35 @@ public final class Thing {
public Builder setSerialNumber(String sn) {
final String name = "SN";
Tag tag = new Tag(name, Type.str, sn);
Tag tag = new Tag(name, Tag.Type.str, sn);
metaTags.put(name, tag);
return this;
}
public Builder setKey(String key) {
final String name = "KEY";
Tag tag = new Tag(name, Type.str, key);
Tag tag = new Tag(name, Tag.Type.str, key);
metaTags.put(name, tag);
return this;
}
public Builder setManufacturer(String manufacturer) {
final String name = "MAN";
Tag tag = new Tag(name, Type.str, manufacturer);
Tag tag = new Tag(name, Tag.Type.str, manufacturer);
metaTags.put(name, tag);
return this;
}
public Builder setModel(String model) {
final String name = "MODEL";
Tag tag = new Tag(name, Type.str, model);
Tag tag = new Tag(name, Tag.Type.str, model);
metaTags.put(name, tag);
return this;
}
public Builder setVersion(String version) {
final String name = "V";
Tag tag = new Tag(name, Type.num, version);
Tag tag = new Tag(name, Tag.Type.num, version);
metaTags.put(name, tag);
return this;
}

@ -1,6 +1,6 @@
/**
*
* Copyright © 2016-2019 Florian Schmaus
* Copyright © 2016-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,8 +24,6 @@ import java.util.List;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
@ -45,7 +43,8 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName());
@Override
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackTextParseException {
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws IOException, XmlPullParserException, ParseException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
boolean done = ParserUtils.getBooleanAttribute(parser, "done", false);
List<NodeElement> nodes = new ArrayList<>();
@ -74,7 +73,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
return new IoTFieldsExtension(seqNr, done, nodes);
}
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth();
final NodeInfo nodeInfo = NodeInfoParser.parse(parser);
List<TimestampElement> timestampElements = new ArrayList<>();
@ -103,15 +102,11 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
return new NodeElement(nodeInfo, timestampElements);
}
public TimestampElement parseTimestampElement(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
public TimestampElement parseTimestampElement(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth();
final String dateString = parser.getAttributeValue(null, "value");
Date date;
try {
date = XmppDateTime.parseDate(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
Date date = XmppDateTime.parseDate(dateString);
List<IoTDataField> fields = new ArrayList<>();
outerloop: while (true) {
final XmlPullParser.Event eventType = parser.next();

@ -1,6 +1,6 @@
/**
*
* Copyright 2016-2019 Florian Schmaus
* Copyright 2016-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
@ -201,7 +200,7 @@ public final class IoTProvisioningManager extends Manager {
}, FRIEND_MESSAGE);
connection.registerIQRequestHandler(
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, Type.set, Mode.async) {
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, IQ.Type.set, Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
if (!isFromProvisioningService(iqRequest, true)) {

@ -44,7 +44,7 @@ public class JingleFileTransferProvider
extends JingleContentDescriptionProvider<JingleFileTransfer> {
@Override
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
@ -59,11 +59,7 @@ public class JingleFileTransferProvider
elementName = parser.getName();
switch (elementName) {
case JingleFileTransferChild.ELEM_DATE:
try {
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
break;
case JingleFileTransferChild.ELEM_DESC:

@ -1,6 +1,6 @@
/**
*
* Copyright 2016 Fernando Ramirez, 2020 Florian Schmaus
* Copyright 2016 Fernando Ramirez, 2020-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.mam.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> {
@Override
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Forwarded<Message> forwarded = null;
String queryId = parser.getAttributeValue("", "queryid");
String id = parser.getAttributeValue("", "id");

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.message_retraction.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -34,7 +35,7 @@ public class RetractedElementProvider extends ExtensionElementProvider<Retracted
@Override
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
OriginIdElement originIdElement = null;