Class CacheBlockingOnEvictionTest

java.lang.Object
de.hybris.platform.regioncache.test.CacheBlockingOnEvictionTest

@UnitTest @ContextConfiguration(locations="/test/CacheBlockingOnEvictionTest-context.xml") @DirtiesContext(classMode=AFTER_CLASS) public class CacheBlockingOnEvictionTest extends Object
  • Field Details

  • Constructor Details

    • CacheBlockingOnEvictionTest

      public CacheBlockingOnEvictionTest()
  • Method Details

    • init

      public void init()
    • clean

      public void clean()
    • cleanEHCache

      public static void cleanEHCache()
    • testCacheEvictionDeadlock

      public void testCacheEvictionDeadlock()
      This test tries to verify that eviction does not lead to a deadlock. Deadlock can occur because of the following steps: 1.) Registrable key is added to a cache by a client. 2.) Cache controller adds the key to proper registry, with a "callback" that inserts the key/value pair into the cache region map. 3.) Cache registry acquires a lock for "registering". This lock is exclusive for registering, no invalidation or eviction can happen in parallel. 4.) Cache registry registers the key 5.) Cache registry executes callback 6.) Callback inserts new entry into region map. If the region map is full, region map EVICTION happens. 7.) Region map eviction causes region map eviction callback to execute. 8.) Cache controller captures the callback and routes it AGAIN to cache registry to remove possible registration for just-evicted key. 9.) Cache registry in "evict" method tries to acquire a lock for evicting. BUT... The cache registry already holds a lock for registering - see. 3.) We have a deadlock now. This problem is solved by "delaying" such evictions, so that two mutually exclusive locks does not have to be acquired at once, but one after another (first registration, then eviction). How to make the test fail? Disable delayed eviction logic in evict method inside DefaultCacheRegistry.
    • testCacheEvictionDeadlock2

      public void testCacheEvictionDeadlock2()