aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-08-05 22:00:31 +0300
committerGravatar Vitaly Takmazov2018-08-05 22:00:31 +0300
commit830daff160930fa185d5b8ffdc64516d1ef03218 (patch)
treef7c2ae2d98f34d33b4aa37301d3fdbaf05a21f04 /juick-server/src/main/java/com/juick/server
parentff58300004b2dfa283650bda33b29f11e2821173 (diff)
XMPP: fix stream:error parser
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java27
-rw-r--r--juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java2
2 files changed, 21 insertions, 8 deletions
diff --git a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java b/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java
index 7eacfc94..f731f039 100644
--- a/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java
+++ b/juick-server/src/main/java/com/juick/server/xmpp/router/StreamError.java
@@ -12,6 +12,7 @@ import java.io.IOException;
public class StreamError {
private String condition;
+ private String text;
public StreamError() {}
@@ -21,13 +22,21 @@ public class StreamError {
public static StreamError parse(XmlPullParser parser) throws IOException, XmlPullParserException {
StreamError streamError = new StreamError();
- while (parser.next() == XmlPullParser.START_TAG) {
- final String tag = parser.getName();
- final String xmlns = parser.getNamespace();
- if (xmlns.equals(StreamNamespaces.NS_XMPP_STREAMS)) {
- streamError.condition = tag;
- } else {
- XmlUtils.skip(parser);
+ final int initial = parser.getDepth();
+ while (true) {
+ int eventType = parser.next();
+ if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initial + 1) {
+ final String tag = parser.getName();
+ final String xmlns = parser.getNamespace();
+ if (tag.equals("text") && xmlns.equals(StreamNamespaces.NS_XMPP_STREAMS)) {
+ streamError.text = XmlUtils.getTagText(parser);
+ } else if (xmlns.equals(StreamNamespaces.NS_XMPP_STREAMS)) {
+ streamError.condition = tag;
+ } else {
+ XmlUtils.skip(parser);
+ }
+ } else if (eventType == XmlPullParser.END_TAG && parser.getDepth() == initial) {
+ break;
}
}
return streamError;
@@ -41,4 +50,8 @@ public class StreamError {
public String toString() {
return String.format("<stream:error><%s xmlns='%s'/></stream:error>", condition, StreamNamespaces.NS_XMPP_STREAMS);
}
+
+ public String getText() {
+ return text;
+ }
}
diff --git a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java b/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java
index 9c8e375c..72c3ba8d 100644
--- a/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java
+++ b/juick-server/src/main/java/com/juick/server/xmpp/s2s/ConnectionIn.java
@@ -156,7 +156,7 @@ public class ConnectionIn extends Connection implements Runnable {
restartParser();
} else if (tag.equals("error")) {
StreamError streamError = StreamError.parse(parser);
- logger.debug("Stream error from {}: {}", streamID, streamError.getCondition());
+ logger.debug("Stream error {} from {}: {}", streamError.getCondition(), streamID, streamError.getText());
xmpp.removeConnectionIn(this);
closeConnection();
} else {