Skip to content
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 <abonnairesergeant@gmail.com>
  • Loading branch information...
1 parent ded016d commit 8aac045991a0486a68d7a653cb02cff27d27c574 @pjstadig pjstadig committed with frenchy64 Feb 9, 2013
Showing with 1 addition and 2 deletions.
  1. +1 −2 src/main/clojure/clojure/core/cache.clj
View
3 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)
this)

0 comments on commit 8aac045

Please sign in to comment.
Something went wrong with that request. Please try again.