mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-22 18:48:00 +01:00
Set conditionText to null if it's the empty string
This fixes e.g. IllegalArgumentException "'conflict' can not contain a condition text", when receiving elements like <stream:error> <conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'></conflict> <text xml:lang='' xmlns='urn:ietf:params:xml:ns:xmpp-streams'> Replaced by new connection </text> </sream:error> (ejabberd does this)
This commit is contained in:
parent
c89d06861b
commit
7640414e8d
2 changed files with 14 additions and 0 deletions
|
@ -20,6 +20,7 @@ package org.jivesoftware.smack.packet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,6 +106,12 @@ public class StreamError extends AbstractError implements PlainStreamElement {
|
||||||
|
|
||||||
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<PacketExtension> extensions) {
|
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<PacketExtension> extensions) {
|
||||||
super(descriptiveTexts, extensions);
|
super(descriptiveTexts, extensions);
|
||||||
|
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||||
|
// <condition xmlns='foo'></condition>, in this case the parser may calls this constructor with the empty string
|
||||||
|
// as conditionText, therefore reset it to null if it's the empty string
|
||||||
|
if (StringUtils.isNullOrEmpty(conditionText)) {
|
||||||
|
conditionText = null;
|
||||||
|
}
|
||||||
if (conditionText != null) {
|
if (conditionText != null) {
|
||||||
switch (condition) {
|
switch (condition) {
|
||||||
case see_other_host:
|
case see_other_host:
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +118,12 @@ public class XMPPError extends AbstractError {
|
||||||
List<PacketExtension> extensions) {
|
List<PacketExtension> extensions) {
|
||||||
super(descriptiveTexts, NAMESPACE, extensions);
|
super(descriptiveTexts, NAMESPACE, extensions);
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
|
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||||
|
// <condition xmlns='foo'></condition>, in this case the parser may calls this constructor with the empty string
|
||||||
|
// as conditionText, therefore reset it to null if it's the empty string
|
||||||
|
if (StringUtils.isNullOrEmpty(conditionText)) {
|
||||||
|
conditionText = null;
|
||||||
|
}
|
||||||
if (conditionText != null) {
|
if (conditionText != null) {
|
||||||
switch (condition) {
|
switch (condition) {
|
||||||
case gone:
|
case gone:
|
||||||
|
|
Loading…
Reference in a new issue