ensure callback is always completed in WebSocketCoreSession

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2024-01-24 12:00:46 +11:00
parent 1e0c0b42ab
commit 6b20ee0753
1 changed files with 10 additions and 0 deletions

View File

@ -317,12 +317,22 @@ public class WebSocketCoreSession implements CoreSession, Dumpable
CloseStatus closeStatus = new CloseStatus(code, cause);
if (CloseStatus.isTransmittableStatusCode(code))
{
close(closeStatus, callback);
}
else
{
if (sessionState.onClosed(closeStatus))
{
closeConnection(closeStatus, callback);
}
else
{
// We are already closed because of a previous failure.
// Succeed because failing might re-enter this branch if it's the Frame callback.
callback.succeeded();
}
}
}
/**