Uploaded image for project: 'Cocoon'
  1. Cocoon
  2. COCOON-2109

Incorrent cleanup of expired continuations


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.11
    • Fix Version/s: 2.1.12
    • Component/s: * Cocoon Core
    • Labels:
    • Urgency:
    • Other Info:
      Patch available
    • Affects version (Component):
      Cocoon Core
    • Fix version (Component):
      Cocoon Core


      The class ContinuationsManagerImpl is in charge of cleaning up expired continuations. It does so in the method expireContinuations. In this method there is a loop using an iterator over a SortedSet of continuations (WebContinuation). The loop is expecting that the continuations are ordered from oldest to newest. The loop stops in the first continuation that is not expired. The logic is correct since all the newer continuations could not be expired.

      However, the problem comes from the ordering of the continuations. To have the continuations ordered by lastAccessTime the program uses a TreeSet as a container of the continuations. The continuations implement the compareTo interface using the lastAccessTime and when a continuation is inserted in the container, it gets correctly ordered. But after the insertion, the continuation can change its lastAccessTime using the method WebContinuation.updateLastAccessTime() called from WebContinuation.getContinuation(). The ordering of the TreeSet is not updated with the change and when the program iterates over it, it does not get the continuations in the order expected.

      The result of this bug is that under hevy load many expired continuations may be around before the loop actually clean them up, eating memory resources and causing OutOfMemory.

      To fix it, a patch is provided that uses a HashSet for the continuations container and loops over all the continuations to check if they have expired.




            • Assignee:
              joerg.heinicke@gmx.de Jörg Heinicke
              mcuervoe Miguel Cuervo
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: