ConfluenceVelocityResourceCache causes stack overflow if "A FakeSerializableResource has been serialized"

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Medium
    • 3.0
    • Affects Version/s: 2.7.3, 2.8, 2.8.1, 2.8.2, 2.9, 2.9.1, 2.9.2
    • Component/s: None
    • Environment:

      Noticed the problem in a 2 node cluster running 2.7.3

      we are working on https://support.atlassian.com/browse/CSP-26648 and after examining the code of ConfluenceVelocityResourceCache found that there is a unchecked recursive loop:

      • In getResource() if the holder exists but the resource is null, it will try to remove()
      • What is the very first thing remove() does? you guested it getResource()

      I don't understand the logic, and I guess it is an very unlikely scenario, but it is happening (see https://support.atlassian.com/browse/CSP-26648).

      Could somebody shed some light?

      See code below:

          public Resource remove(Object key)
          {
              runtimeServices.debug("Removing " + key + " from cache" );
              try
              {
                  Resource resource = getResource(key);
                  cache.remove(key);
                  return resource;
              }
              catch (Exception e)
              {
                  log.error("Error removing cache key '" + key + "'", e);
              }
              return null;
          }
          ...
      
          private Resource getResource(Object key) 
          {
              if ("true".equalsIgnoreCase(System.getProperty("atlassian.disable.caches")))
                  return null;
      
              FakeSerializableResource holder = (FakeSerializableResource) cache.get(key);
              if (holder == null)
                  return null;
      
              Resource resource = holder.get();
              if (resource == null)
              {
                  log.warn("A FakeSerializableResource has been serialized");
                  remove(key);
              }
              return resource;
          }
      

              Assignee:
              Don Willis
              Reporter:
              Roberto Dominguez
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: