Atmosphere/atmosphere — Issue #81: Long-polling / jersey "bug"
Author: haed
Created: 2011-11-25 23:07:49+00:00
State: open

I think i found a bug (happens only on long-polling on sending much messages in a short period of time).

1. broadcaster.broadcast("message1") -> m1 goes to the asyncWriteHandler (delays execution)
2. broadcaster.broadcast("message2") -> m2 goes also to the asyncWriteHandler
3. message1 reaches JerseyBroadCaster#broadcast (as next token in the asyncWriteQueue => executeAsyncWrite())
4. long-polling = resumeOnBroadcast, at the end of JerseyBroadCaster#broadcast for message1 the connection will be resumed
5. message2 is reaching the asyncWrite-cycle (connection does not suspend yet)

=> Error! JerseyBroadcaster#42 is reached, ContainerResponse is null!

You can debug this, if you "disable" connection suspending by a breakpoint (1) (e.g. AtmosphereFilter#266) and another breakpoint (2) before broadcast (e.g. JerseyBroadcasterUtil#38), here are the steps to produce the error:

1. send message1 => breaks in (2)
2. send message2 => message2 will be added also to the asyncWriteQueue
3. start break of message1 => message will be delivered, connection resumes, breaks on (1) (avoid suspending)
4. start break of message2 => error in JerseyBroadcaster#42