From 9178f384657711b29ad6f68ae409607271c37ffe Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Wed, 9 Nov 2016 06:20:10 -0500 Subject: [PATCH] fix race condition relating to retrieving path from cache and aot compilation --- src/clj/com/rpl/specter.cljc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/clj/com/rpl/specter.cljc b/src/clj/com/rpl/specter.cljc index 20a6cf3..2b52959 100644 --- a/src/clj/com/rpl/specter.cljc +++ b/src/clj/com/rpl/specter.cljc @@ -232,8 +232,13 @@ get-cache-code (if (= platform :clj) `(try (i/get-cell ~cache-sym) (catch ClassCastException e# + ;; With AOT compilation it's possible for: + ;; Thread 1: unbound, so throw exception + ;; Thread 2: unbound, so throw exception + ;; Thread 1: do alter-var-root + ;; Thread 2: it's bound, so retrieve the current value (if (bound? (var ~cache-sym)) - (throw e#) + (i/get-cell ~cache-sym) (do (alter-var-root (var ~cache-sym)