eclipse-ee4j / tyrus

Tyrus
Other
115 stars 37 forks source link

Fix race condition causing unexpected idle disconnections #846

Closed nyckyta closed 1 year ago

nyckyta commented 1 year ago

This issue may appear when 'send[data]' methods are triggered from different threads. As a result threads race appears between cancelIdleTimeoutExecutor and scheduling new idle task. Example of race:

  1. Thread 1 cancels task
  2. Thread 2 waits until thread 1 will finish
  3. Thread 1 finishes
  4. Thread 2 tries to cancel already cancelled task and leaves synchronized block
  5. Thread 1 schedules new idle task
  6. Thread 2 schedules another idle task, the first is overwritten and never cancelled. As a result disconnection is triggered precisely after set idle timeout passes.

I would appreciate if this fix will be added to the version responsible for Java 1.x implementation, since this is one we still use in our internal project.

nyckyta commented 1 year ago

@jansupol Should I do something additionaly to request review? There is no hurry, but I just want to make sure that this PR won't stuck here for unknown reason.

nyckyta commented 1 year ago

@rok-povsic FYI, when this is released, dev build version must be replaced by the release (1.21). (Unless something has changed of course).