Commit 2a4c54c3 authored by Christian Schudt's avatar Christian Schudt Committed by daryl herzmann

Gracefully close the stream with </stream:stream> (#770)

Fixes OF-1308
parent 34971f95
......@@ -220,18 +220,18 @@ public class NIOConnection implements Connection {
// Ensure that the state of this connection, its session and the MINA context are eventually closed.
if ( session != null ) {
session.setStatus( Session.STATUS_CLOSED );
if (session != null) {
session.setStatus(Session.STATUS_CLOSED);
}
try {
deliverRawText( flashClient ? "</flash:stream>" : "</stream:stream>" );
} catch ( Exception e ) {
deliverRawText0(flashClient ? "</flash:stream>" : "</stream:stream>");
} catch (Exception e) {
Log.error("Failed to deliver stream close tag: " + e.getMessage());
}
try {
ioSession.close( true );
ioSession.close(true);
} catch (Exception e) {
Log.error("Exception while closing MINA session", e);
}
......@@ -317,6 +317,11 @@ public class NIOConnection implements Connection {
@Override
public void deliverRawText(String text) {
if (!isClosed()) {
deliverRawText0(text);
}
}
private void deliverRawText0(String text){
boolean errorDelivering = false;
IoBuffer buffer = IoBuffer.allocate(text.length());
buffer.setAutoExpand(true);
......@@ -346,7 +351,6 @@ public class NIOConnection implements Connection {
close();
}
}
}
@Deprecated
@Override
......
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