Uploaded image for project: 'ActiveMQ'
  1. ActiveMQ
  2. AMQ-1205 Memory leak in Scheduler
  3. AMQ-1235

Scheduler.cancel uses incorrect argument to shutdown threads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 4.1.1
    • 4.1.2, 5.0.0
    • None
    • None

    Description

      looking at the code from 4.1.1 in org.apache.activemq.thread.Scheduler, in the cancel method:

      the Runnable task argument is passed to clockDaemon.remove(). i think this is incorrect. ScheduledFuture ticket should be passed to clockDaemon.remove().

      the javadocs of ScheduledThreadPoolExecutor.remove discuss the possibility that Runnables might be stored in some other form internally, so calling remove with a plain Runnable might not do anything. I think the solution is to call remove with a ScheduledFuture, which is how they are stored internally in ScheduledThreadPoolExecutor.

      i came across this bug after upgrading to the java 5 version of backport-util-concurrent 3.0. that version makes more assumptions about the types that are passed into ScheduledThreadPoolExecutor.remove, so when you pass in a regular Runnable you'll get a ClassCastException.

      this is trivial to fix, so i don't think a patch is necessary. also i think this might address the memory leak mentioned in AMQ-1205

      Attachments

        1. scheduler.patch
          1.0 kB
          Alex Burgel

        Activity

          People

            chirino Hiram R. Chirino
            aburgel Alex Burgel
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: