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