diff --git a/src/java/org/jivesoftware/multiplexer/net/ConnectionHandler.java b/src/java/org/jivesoftware/multiplexer/net/ConnectionHandler.java index 1bfc7e6..b6cca5c 100644 --- a/src/java/org/jivesoftware/multiplexer/net/ConnectionHandler.java +++ b/src/java/org/jivesoftware/multiplexer/net/ConnectionHandler.java @@ -111,24 +111,25 @@ public void exceptionCaught(IoSession session, Throwable cause) throws Exception { if (cause instanceof IOException) { // TODO Verify if there were packets pending to be sent and decide what to do with them - Log.debug("ConnectionHandler: ",cause); - } - else if (cause instanceof XMLNotWellFormedException) { - Log.warn("Closing session due to malformed XML: " + session, cause); - final Connection connection = (Connection) session.getAttribute(CONNECTION); - final StreamError error = new StreamError(StreamError.Condition.xml_not_well_formed); - connection.deliverRawText(error.toXML()); - session.close(); + Log.info("ConnectionHandler reports IOException for session: " + session, cause); } else if (cause instanceof ProtocolDecoderException) { Log.warn("Closing session due to exception: " + session, cause); + + // PIO-524: Determine stream:error message. + final StreamError error; + if (cause.getCause() != null && cause.getCause() instanceof XMLNotWellFormedException) { + error = new StreamError(StreamError.Condition.xml_not_well_formed); + } else { + error = new StreamError(StreamError.Condition.internal_server_error); + } + final Connection connection = (Connection) session.getAttribute(CONNECTION); - final StreamError error = new StreamError(StreamError.Condition.internal_server_error); connection.deliverRawText(error.toXML()); session.close(); } else { - Log.error(cause.getMessage(), cause); + Log.error("ConnectionHandler reports unexpected exception for session: " + session, cause); } }