Skip to content

Commit

Permalink
Issue #5193 - fix lost message bug when using single onMessage annota…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Aug 27, 2020
1 parent eebb47c commit 478bcdc
Showing 1 changed file with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class JettyAnnotatedEventDriver extends AbstractEventDriver
private static final Logger LOG = Log.getLogger(JettyAnnotatedEventDriver.class);
private final JettyAnnotatedMetadata events;
private boolean hasCloseBeenCalled = false;
private BatchMode batchMode;
private final BatchMode batchMode;

public JettyAnnotatedEventDriver(WebSocketPolicy policy, Object websocket, JettyAnnotatedMetadata events)
{
Expand Down Expand Up @@ -82,20 +82,14 @@ public BatchMode getBatchMode()
@Override
public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException
{
if (events.onBinary == null)
if (activeMessage == null)
{
// not interested in binary events
if (activeMessage == null)
if (events.onBinary == null)
{
// not interested in binary events
activeMessage = NullMessage.INSTANCE;
}

return;
}

if (activeMessage == null)
{
if (events.onBinary.isStreaming())
else if (events.onBinary.isStreaming())
{
final MessageInputStream inputStream = new MessageInputStream(session);
activeMessage = inputStream;
Expand Down Expand Up @@ -199,19 +193,14 @@ public void onReader(Reader reader)
@Override
public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException
{
if (events.onText == null)
if (activeMessage == null)
{
// not interested in text events
if (activeMessage == null)
if (events.onText == null)
{
// not interested in text events
activeMessage = NullMessage.INSTANCE;
}
return;
}

if (activeMessage == null)
{
if (events.onText.isStreaming())
else if (events.onText.isStreaming())
{
MessageInputStream inputStream = new MessageInputStream(session);
activeMessage = new MessageReader(inputStream);
Expand Down

0 comments on commit 478bcdc

Please sign in to comment.