Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-1583

AbstractDelegatingAdvancedCache with(ClassLoader), withFlags(Flag...) logic is broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 5.2.0.CR2, 5.2.0.Final
    • 5.1.0.BETA5
    • Core
    • None

    Description

      When the withFlags(...) logic was modified to use a DecoratedCache instead of thread-local storage, any caches already decorated with the AbstractDelegatingAdvancedCache(...) broke.

      Take the following code:
      AdvancedCache<K, V> baseCache;
      AdvancedCache<K, V> customCache = new AbstractDelegatingAdvancedCache<K, V>(baseCache) {
      public void clear()

      { // custom clear logic }

      };

      customCache.withFlags(Flag.CACHE_MODE_LOCAL).clear();

      In the above statement, the flag is not applied.
      The call to withFlags(...) returns a reference to customCache, and the reference to DecoratedCache containing the flags is lost to garbage collection.

      In the case of with(ClassLoader) we have the opposite problem.

      customCache.with(customClassLoader).clear();

      In the above statement, the native clear() method is invoked instead of my custom clear() method. with(ClassLoader) returns a reference to DecoratedCache. The clear() method then operates on baseCache, instead of customCache.

      Attachments

        Activity

          People

            rh-ee-galder Galder ZamarreƱo
            pferraro@redhat.com Paul Ferraro
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: