Commit 4e2a0280 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fix that avoids an annoying warning when a client's connection sent an end of stream element.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@729 b35dd754-fafc-0310-a699-88a17e54d16e
parent c1567318
...@@ -175,38 +175,40 @@ public class SocketReadThread extends Thread { ...@@ -175,38 +175,40 @@ public class SocketReadThread extends Thread {
*/ */
private void readStream() throws Exception { private void readStream() throws Exception {
while (true) { while (true) {
Document document = reader.parseDocument(); Element doc = reader.parseDocument().getRootElement();
if (document != null) { if (doc == null) {
Element doc = document.getRootElement(); // Stop reading the stream since the client has sent an end of stream element and
// probably closed the connection
return;
}
String tag = doc.getName(); String tag = doc.getName();
if ("message".equals(tag)) { if ("message".equals(tag)) {
Message packet = new Message(doc); Message packet = new Message(doc);
packet.setFrom(session.getAddress()); packet.setFrom(session.getAddress());
auditor.audit(packet, session); auditor.audit(packet, session);
router.route(packet); router.route(packet);
session.incrementClientPacketCount(); session.incrementClientPacketCount();
} }
else if ("presence".equals(tag)) { else if ("presence".equals(tag)) {
Presence packet = new Presence(doc); Presence packet = new Presence(doc);
packet.setFrom(session.getAddress()); packet.setFrom(session.getAddress());
auditor.audit(packet, session); auditor.audit(packet, session);
router.route(packet); router.route(packet);
session.incrementClientPacketCount(); session.incrementClientPacketCount();
// Update the flag that indicates if the user made a clean sign out // Update the flag that indicates if the user made a clean sign out
clearSignout = (Presence.Type.unavailable == packet.getType() ? true : false); clearSignout = (Presence.Type.unavailable == packet.getType() ? true : false);
} }
else if ("iq".equals(tag)) { else if ("iq".equals(tag)) {
IQ packet = getIQ(doc); IQ packet = getIQ(doc);
packet.setFrom(session.getAddress()); packet.setFrom(session.getAddress());
auditor.audit(packet, session); auditor.audit(packet, session);
router.route(packet); router.route(packet);
session.incrementClientPacketCount(); session.incrementClientPacketCount();
} }
else { else {
throw new XmlPullParserException(LocaleUtils.getLocalizedString("admin.error.packet.tag") + tag); throw new XmlPullParserException(LocaleUtils.getLocalizedString("admin.error.packet.tag") + tag);
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment