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

The size of a local cache could be more accurate under concurrent modifications when expiration is enabled


    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 4.1.0.CR3, 4.1.0.Final
    • 4.0.0.Final, 4.1.0.CR1
    • None
    • None

      I'm totally aware that the cache size is an approximation according to your doc however the value could be improved if in the class DefaultDataContainer in case of cache entry expiration, you first check if the method remove(key) returns a non null value before decrementing the variable numEntries as below otherwise you could decrement it several times for the same entry:

      if (mortalEntries.remove(k) != null) {

      I attached a test case in which I set maxIdle to 0 to make the issue happens more easily. I also attached a patch proposal, it is up to you to apply it or reject it.

        1. ISPN-536.diff
          3 kB
        2. TestCacheSize.java
          6 kB
        3. TestCacheSize.java
          7 kB

            manik_jira Manik Surtani (Inactive)
            nfilotto Nicolas Filotto (Inactive)
            0 Vote for this issue
            0 Start watching this issue