Patch:Code and Test
While using the SoftCache we found a NullPointerException could occur while attempting to clear the cache of any enqueued references. We think this is because the references had been enqueued (presumably as a result of GC) before being evicted. In our case the SoftCache is being used as a base for a TTLCacheQ.
The (slightly reduced) stack-trace is as follows:
The exception is thrown in ConcurrentHashMap when attempting to get the hash-code of the key we're removing but since that key is null the call fails.
I have included a test which causes the same exception and a defensive fix which prevents the exception by not attempting to remove from cache unless we have found the corresponding item in rcache.