Details
-
Feature Request
-
Resolution: Done
-
Major
-
4.0.0.Final, 4.1.0.CR1
-
None
-
None
Description
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) { numEntries.getAndDecrement(); }
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.