use of org.xmpp.packet.StreamError in project Openfire by igniterealtime.
the class ConnectionHandler method exceptionCaught.
@Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
Log.warn("Closing connection due to exception in session: " + session, cause);
try {
// OF-524: Determine stream:error message.
final StreamError error;
if (cause != null && (cause instanceof XMLNotWellFormedException || (cause.getCause() != null && cause.getCause() instanceof XMLNotWellFormedException))) {
error = new StreamError(StreamError.Condition.not_well_formed);
} else {
error = new StreamError(StreamError.Condition.internal_server_error);
}
final Connection connection = (Connection) session.getAttribute(CONNECTION);
// OF-1784: Don't write an error when the source problem is an issue with writing data.
if (JiveGlobals.getBooleanProperty("xmpp.skip-error-delivery-on-write-error.disable", false) || !(cause instanceof WriteException)) {
connection.deliverRawText(error.toXML());
}
} finally {
final Connection connection = (Connection) session.getAttribute(CONNECTION);
if (connection != null) {
connection.close();
}
}
}
Aggregations