jbonofre opened a new pull request, #2206:
URL: https://github.com/apache/activemq/pull/2206

   The static READ_CHECK_TIMER and WRITE_CHECK_TIMER in 
AbstractInactivityMonitor are shared across all transport instances. Java's 
Timer permanently marks itself cancelled when its internal thread exits due to 
an unhandled Error thrown by a TimerTask. SchedulerTimerTask rethrows Error 
subclasses, so an OutOfMemoryError in any timer task kills the shared timer 
thread while the static field remains non-null. All subsequent schedule() calls 
on new connections then throw IllegalStateException ("Timer already 
cancelled"), which propagates to TransportConnector.onAcceptError() and is 
logged as WARN "Could not accept connection: Timer already cancelled."
   
   Fix: wrap the schedule() calls in startConnectCheckTask() and 
startMonitorThreads() in try/catch(IllegalStateException). On catch, the dead 
timer is cancelled (to let its thread exit), replaced with a fresh instance, 
and the task is rescheduled. The guard condition in startConnectCheckTask() is 
also extended with || READ_CHECK_TIMER == null to cover the case where the 
field is unexpectedly null when CHECKER_COUNTER > 0.
   
   Add three regression tests to InactivityMonitorTest covering:
   - READ_CHECK_TIMER cancelled with CHECKER_COUNTER == 0 
(startConnectCheckTask path)
   - READ_CHECK_TIMER cancelled with CHECKER_COUNTER > 0 (production scenario)
   - WRITE_CHECK_TIMER cancelled (startMonitorThreads path)
   
   Tests use Wait.waitFor() instead of Thread.sleep() for reliability on slow 
CI.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to