Just had a look-over of the code and spotted a subtle bug I'd missed
before: the undertaker is potentially going to remove live keys from
the map if the node is loaded again in between (dead-keys-entries) and
(remove ...).

This oughta fix it:

(defn- dead-entries-keys []
  (doall
    (filter identity
      (for [entry node-cache]
        (let [val (.getValue entry)]
          (if (instance? WeakReference val)
            (if-not (.get val)
              [(.getKey entry) val])))))))

(defn- prune-dead-entries []
  (doseq [[k v] (dead-entries-keys)]
    (.remove node-cache k v)))

Now the dead WeakReference is bundled with the key in dead-entries-
keys; prune-dead-entries destructures and uses the atomic two-argument
remove in ConcurrentHashMap to remove the mapping only if the value is
still the dead WeakReference and not something else.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to