diff --git a/build.gradle b/build.gradle
index ee9f7dba9..a9053d234 100644
--- a/build.gradle
+++ b/build.gradle
@@ -15,7 +15,7 @@ buildscript {
}
plugins {
- id 'ru.vyarus.animalsniffer' version '1.4.3'
+ id 'ru.vyarus.animalsniffer' version '1.4.5'
}
apply plugin: 'org.kordamp.gradle.markdown'
diff --git a/resources/releasedocs/changelog.html b/resources/releasedocs/changelog.html
index 5d87462d0..4d51e4594 100644
--- a/resources/releasedocs/changelog.html
+++ b/resources/releasedocs/changelog.html
@@ -141,6 +141,44 @@ hr {
+
4.3.0 -- 2018-08-02
+
+
Bug
+
+
+- [SMACK-759] - PubSubManager.getLeafNode() throws PubSubAssertionError.DiscoInfoNodeAssertionError if node exists but its not a PubSub Node
+
+- [SMACK-814] - NPE when using Node.getAffiliationsAsOwner()
+
+- [SMACK-815] - XEP-0184: DeliveryReceipt requires ID, although the XEP defines it as optional attribute
+
+- [SMACK-818] - EntityCapsManager sends presences with multiple CapsExtension causing disco#info lookup to fail
+
+- [SMACK-819] - ConcurrentModification Exception in MultiUserChatManager.java
+
+- [SMACK-820] - DNSUtil.setDaneProvider() does not set the DANE provider
+
+
+
+
Task
+
+
+- [SMACK-769] - Rename XMPPError to StanzaError
+
+- [SMACK-776] - Remove deprecated reconnection callbacks in ConnectionListener
+
+
+
+
Improvement
+
+
+- [SMACK-761] - Adopt ChatStateManager to new Chat API (chat2)
+
+- [SMACK-812] - Enable ModifierOrder checkstyle check
+
+- [SMACK-816] - SimplePayload should infer the XML element name and namespace
+
+
4.2.4 -- 2018-04-15
diff --git a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java
index 907d7be6f..756c2d885 100644
--- a/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java
+++ b/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java
@@ -39,7 +39,6 @@ import org.jivesoftware.smack.packet.Nonza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
-import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.sasl.packet.SaslStreamElements.SASLFailure;
import org.jivesoftware.smack.sasl.packet.SaslStreamElements.Success;
import org.jivesoftware.smack.util.PacketParserUtils;
@@ -235,7 +234,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
private void sendElement(Element element) {
try {
- send(ComposableBody.builder().setPayloadXML(element.toXML(StreamOpen.CLIENT_NAMESPACE).toString()).build());
+ send(ComposableBody.builder().setPayloadXML(element.toXML(BOSH_URI).toString()).build());
if (element instanceof Stanza) {
firePacketSendingListeners((Stanza) element);
}
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 065980090..017f2b489 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
@@ -96,6 +96,38 @@ import org.minidns.dnsname.DnsName;
import org.xmlpull.v1.XmlPullParser;
+/**
+ * This abstract class is commonly used as super class for XMPP connection mechanisms like TCP and BOSH. Hence it
+ * provides the methods for connection state management, like {@link #connect()}, {@link #login()} and
+ * {@link #disconnect()} (which are deliberately not provided by the {@link XMPPConnection} interface).
+ *
+ * Note: The default entry point to Smack's documentation is {@link XMPPConnection}. If you are getting started
+ * with Smack, then head over to {@link XMPPConnection} and the come back here.
+ *
+ *
Parsing Exceptions
+ *
+ * In case a Smack parser (Provider) throws those exceptions are handled over to the {@link ParsingExceptionCallback}. A
+ * common cause for a provider throwing is illegal input, for example a non-numeric String where only Integers are
+ * allowed. Smack's default behavior follows the "fail-hard per default" principle leading to a
+ * termination of the connection on parsing exceptions. This default was chosen to make users eventually aware that they
+ * should configure their own callback and handle those exceptions to prevent the disconnect. Handle a parsing exception
+ * could be as simple as using a non-throwing no-op callback, which would cause the faulty stream element to be taken
+ * out of the stream, i.e., Smack behaves like that element was never received.
+ *
+ *
+ * If the parsing exception is because Smack received illegal input, then please consider informing the authors of the
+ * originating entity about that. If it was thrown because of an bug in a Smack parser, then please consider filling a
+ * bug with Smack.
+ *
+ *
Managing the parsing exception callback
+ *
+ * The "fail-hard per default" behavior is achieved by using the
+ * {@link org.jivesoftware.smack.parsing.ExceptionThrowingCallbackWithHint} as default parsing exception callback. You
+ * can change the behavior using {@link #setParsingExceptionCallback(ParsingExceptionCallback)} to set a new callback.
+ * Use {@link org.jivesoftware.smack.SmackConfiguration#setDefaultParsingExceptionCallback(ParsingExceptionCallback)} to
+ * set the default callback.
+ *
+ */
public abstract class AbstractXMPPConnection implements XMPPConnection {
private static final Logger LOGGER = Logger.getLogger(AbstractXMPPConnection.class.getName());
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java
index 4b99bc20f..01f2995a4 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java
@@ -29,7 +29,7 @@ import javax.net.ssl.HostnameVerifier;
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
import org.jivesoftware.smack.debugger.ReflectionDebuggerFactory;
import org.jivesoftware.smack.debugger.SmackDebuggerFactory;
-import org.jivesoftware.smack.parsing.ExceptionThrowingCallback;
+import org.jivesoftware.smack.parsing.ExceptionThrowingCallbackWithHint;
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
import org.jivesoftware.smack.util.Objects;
@@ -80,7 +80,7 @@ public final class SmackConfiguration {
* The default parsing exception callback is {@link ExceptionThrowingCallback} which will
* throw an exception and therefore disconnect the active connection.
*/
- private static ParsingExceptionCallback defaultCallback = new ExceptionThrowingCallback();
+ private static ParsingExceptionCallback defaultCallback = new ExceptionThrowingCallbackWithHint();
private static HostnameVerifier defaultHostnameVerififer;
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java
index 92ef0a964..09fa9178e 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java
@@ -137,7 +137,7 @@ public abstract class IQ extends Stanza {
buf.attribute("type", type.toString());
}
buf.rightAngleBracket();
- buf.append(getChildElementXML());
+ buf.append(getChildElementXML(enclosingNamespace));
buf.closeElement(IQ_ELEMENT);
return buf;
}
@@ -149,10 +149,22 @@ public abstract class IQ extends Stanza {
* @return the child element section of the IQ XML.
*/
public final XmlStringBuilder getChildElementXML() {
+ return getChildElementXML(null);
+ }
+
+ /**
+ * Returns the sub-element XML section of the IQ packet, or the empty String if there
+ * isn't one.
+ *
+ * @param enclosingNamespace the enclosing XML namespace.
+ * @return the child element section of the IQ XML.
+ * @since 4.3.0
+ */
+ public final XmlStringBuilder getChildElementXML(String enclosingNamespace) {
XmlStringBuilder xml = new XmlStringBuilder();
if (type == Type.error) {
// Add the error sub-packet, if there is one.
- appendErrorIfExists(xml);
+ appendErrorIfExists(xml, enclosingNamespace);
}
else if (childElementName != null) {
// Add the query section if there is one.
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java
index cb87251c7..ee22034c5 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java
@@ -501,7 +501,7 @@ public final class Message extends Stanza implements TypedCloneable
{
buf.optElement("thread", thread);
// Append the error subpacket if the message type is an error.
if (type == Type.error) {
- appendErrorIfExists(buf);
+ appendErrorIfExists(buf, enclosingNamespace);
}
// Add extension elements, if any are defined.
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java
index abf4e39c5..99a0b8ae1 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Presence.java
@@ -292,7 +292,7 @@ public final class Presence extends Stanza implements TypedCloneable {
buf.append(getExtensions(), enclosingNamespace);
// Add the error sub-packet, if there is one.
- appendErrorIfExists(buf);
+ appendErrorIfExists(buf, enclosingNamespace);
buf.closeElement(ELEMENT);
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
index c749a3214..3104870e0 100644
--- a/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
+++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
@@ -541,10 +541,10 @@ public abstract class Stanza implements TopLevelStreamElement {
*
* @param xml the XmlStringBuilder to append the error to.
*/
- protected void appendErrorIfExists(XmlStringBuilder xml) {
+ protected void appendErrorIfExists(XmlStringBuilder xml, String enclosingNamespace) {
StanzaError error = getError();
if (error != null) {
- xml.append(error.toXML());
+ xml.append(error.toXML(enclosingNamespace));
}
}
}
diff --git a/smack-core/src/main/java/org/jivesoftware/smack/parsing/ExceptionThrowingCallbackWithHint.java b/smack-core/src/main/java/org/jivesoftware/smack/parsing/ExceptionThrowingCallbackWithHint.java
new file mode 100644
index 000000000..299b21242
--- /dev/null
+++ b/smack-core/src/main/java/org/jivesoftware/smack/parsing/ExceptionThrowingCallbackWithHint.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2018 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.parsing;
+
+import java.util.logging.Logger;
+
+import org.jivesoftware.smack.UnparseableStanza;
+
+/**
+ * Like {@link ExceptionThrowingCallback} but additionally logs a warning message.
+ *
+ * @author Florian Schmaus
+ *
+ */
+public class ExceptionThrowingCallbackWithHint extends ExceptionThrowingCallback {
+
+ private static final Logger LOGGER = Logger.getLogger(ExceptionThrowingCallbackWithHint.class.getName());
+
+ @Override
+ public void handleUnparsableStanza(UnparseableStanza packetData) throws Exception {
+ LOGGER.warning("Parsing exception encountered."
+ + " This exception will be re-thrown, leading to a disconnect."
+ + " You can change this behavior by setting a different ParsingExceptionCallback using setParsingExceptionCallback()."
+ + " More information an be found in AbstractXMPPConnection's javadoc.");
+
+ super.handleUnparsableStanza(packetData);
+ }
+}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoCopyHint.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoCopyHint.java
index b07249ddd..a22a0f7b7 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoCopyHint.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoCopyHint.java
@@ -56,6 +56,6 @@ public final class NoCopyHint extends MessageProcessingHint {
}
public static void set(Message message) {
- message.addExtension(INSTANCE);
+ message.overrideExtension(INSTANCE);
}
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoPermanentStoreHint.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoPermanentStoreHint.java
index bd3bac500..ff27c5bb1 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoPermanentStoreHint.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoPermanentStoreHint.java
@@ -60,7 +60,7 @@ public final class NoPermanentStoreHint extends MessageProcessingHint {
// No need to set the no-permanent-store hint when a no-store hint is already set.
return;
}
- setExplicitly(message);
+ message.overrideExtension(INSTANCE);
}
public static void setExplicitly(Message message) {
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoStoreHint.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoStoreHint.java
index 508812ec9..78e0f731a 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoStoreHint.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/NoStoreHint.java
@@ -56,6 +56,6 @@ public final class NoStoreHint extends MessageProcessingHint {
}
public static void set(Message message) {
- message.addExtension(INSTANCE);
+ message.overrideExtension(INSTANCE);
}
}
diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/StoreHint.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/StoreHint.java
index f468514b1..fdbed6cb3 100644
--- a/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/StoreHint.java
+++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/hints/element/StoreHint.java
@@ -56,6 +56,6 @@ public final class StoreHint extends MessageProcessingHint {
}
public static void set(Message message) {
- message.addExtension(INSTANCE);
+ message.overrideExtension(INSTANCE);
}
}