Menu

#29 free resources properly in DNSStatefulObjectSemaphore

closed-rejected
None
5
2012-03-30
2012-03-30
Anonymous
No

method signalEvent() in DNSStatefulObjectSemaphore was not removing semaphores from the correct collection, it was removing them from the local copy (used only for iteration), and not actually from the class's ConcurrentHashMap - thus it was holding/'leaking' resources, including references to threads (ouch), preventing garbage collection.

Patch is a one-liner! :)

Discussion

  • Anonymous

    Anonymous - 2012-03-30

    actually, i'll admit that i'm not overly familiar with the code, so please feel free to reject my patch if the original code is as-intended,

     
  • Pierre Frisch

    Pierre Frisch - 2012-03-30

    The code is actually correct. If you check the JavaDoc for the ConcurrentHashMap the method values() return a live collection backed by the map and it explicitly state that removal of an element in the collection remove an element in the map.

    Cheers

    Pierre

     
  • Pierre Frisch

    Pierre Frisch - 2012-03-30
    • assigned_to: nobody --> spearway
    • status: open --> pending-rejected
     
  • Anonymous

    Anonymous - 2012-03-30

    ah ok - yes, you're correct - sorry for the oversight.