jsr356-experts@websocket-spec.java.net

[jsr356-experts] Re: Endpoint.onOpen() and Session.addMessageHandler() race condition

From: Joakim Erdfelt <joakim_at_intalio.com>
Date: Thu, 18 Apr 2013 15:02:54 -0700

I opened this as another spec clarification bug at
http://java.net/jira/browse/WEBSOCKET_SPEC-191


--
Joakim Erdfelt <joakim_at_intalio.com>
webtide.com <http://www.webtide.com/>
Developer advice, services and support
from the Jetty & CometD experts
eclipse.org/jetty - cometd.org
On Tue, Apr 9, 2013 at 7:05 PM, Mark Thomas <mark_at_homeinbox.net> wrote:
> On 03/04/2013 14:16, Joakim Erdfelt wrote:
>
>> A scenario for the group to ponder.
>>
>>  1. You have a ChatEndpoint extends Endpoint class.
>>  2. WebSocket has been upgraded
>>  3. Remote starts immediately sending text frames/messages.
>>  4. Endpoint.onOpen(Session session, EndpointConfig config) is called.
>>  5. ChatEndpoint.onOpen() performs a session.addMessageHandler(new
>>
>>     ChatMessageHandler()) call.
>>
>> If the implementation starts pushing those received messages as it gets
>> them, then this gap of time between the open and
>> session.addMessageHandler() can result in lost messages.
>>
>> Is there a requirement in the spec somewhere that says processing of
>> received messages should not start until the Endpoint.onOpen (or
>> @OnOpen) call has completed?
>> Would seem to make sense.
>>
>
> +1
>
> Mark
>
>
>