Issue #3290 async onOpen, onClose and onError

Changes after review:
 + failure to send abnormal close closes connection prior to failing
   callback.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2019-01-29 10:45:54 +11:00
parent 6f7395c8f0
commit 3ad584eaef
1 changed files with 14 additions and 11 deletions

View File

@ -524,19 +524,22 @@ public class WebSocketChannel implements IncomingFrames, FrameHandler.CoreSessio
}
catch (Throwable ex)
{
try
if (frame.getOpCode() == OpCode.CLOSE)
{
CloseStatus closeStatus = CloseStatus.getCloseStatus(frame);
if (closeStatus instanceof AbnormalCloseStatus)
closeConnection(null, closeStatus, Callback.from(
()->callback.failed(ex),
x2->
{
ex.addSuppressed(x2);
callback.failed(ex);
}));
else
callback.failed(ex);
}
else
callback.failed(ex);
}
finally
{
if (frame.getOpCode() == OpCode.CLOSE)
{
CloseStatus closeStatus = CloseStatus.getCloseStatus(frame);
if (closeStatus instanceof AbnormalCloseStatus)
closeConnection(null, closeStatus, NOOP);
}
}
}
}