Browse files

CCACHE-28: fixes concurrency bug in has?

We were allowing for another thread to add an item to the cache after we'd
already tried to pull out the SoftReference.  Since the SoftReference had been
pulled out before the item was added, it was nil, but since contains? returned
true, we assumed that it was not nil.

Signed-off-by: Ambrose Bonnaire-Sergeant <>
  • Loading branch information...
pjstadig authored and frenchy64 committed Feb 9, 2013
1 parent ded016d commit 8aac045991a0486a68d7a653cb02cff27d27c574
Showing with 1 addition and 2 deletions.
  1. +1 −2 src/main/clojure/clojure/core/cache.clj
@@ -509,8 +509,7 @@
(has? [_ item]
(let [item (or item ::nil)
^SoftReference cell (get cache item)]
- (and (contains? cache item)
- (not (nil? (.get cell))))))
+ (and cell (.get cell))))
(hit [this item]
(clear-soft-cache! cache rcache rq)

0 comments on commit 8aac045

Please sign in to comment.