diff --git a/project.clj b/project.clj index 99008b4..d505ffc 100644 --- a/project.clj +++ b/project.clj @@ -14,7 +14,7 @@ :dependencies [[org.clojure/tools.reader "1.3.3"] - [com.taoensso/encore "2.127.0"] + [com.taoensso/encore "3.0.0"] [org.iq80.snappy/snappy "0.4"] [org.tukaani/xz "1.8"] [org.lz4/lz4-java "1.7.1"]] diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index 3cb5b77..640327f 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -954,7 +954,7 @@ See also `cache`." [& body] `(try - (.set -cache-proxy (enc/-vol! nil)) + (.set -cache-proxy (volatile! nil)) (do ~@body) (finally (.remove -cache-proxy)))) @@ -980,7 +980,7 @@ ?idx (get cache k) ^int idx (or ?idx (let [idx (count cache)] - (enc/-vol-swap! cache_ assoc k idx) + (vswap! cache_ assoc k idx) idx)) first-occurance? (nil? ?idx)] @@ -1023,7 +1023,7 @@ (let [v (get @cache_ idx not-found)] (if (identical? v not-found) (let [x (thaw-from-in! in)] - (enc/-vol-swap! cache_ assoc idx x) + (vswap! cache_ assoc idx x) x) v)) (throw (ex-info "No cache_ established, can't thaw. See `with-cache`." diff --git a/src/taoensso/nippy/crypto.clj b/src/taoensso/nippy/crypto.clj index 5d6a6a7..1815d13 100644 --- a/src/taoensso/nippy/crypto.clj +++ b/src/taoensso/nippy/crypto.clj @@ -11,14 +11,14 @@ ;;;; Randomness (do - (defn rand-nth [coll] (nth coll (int (* (.nextDouble (enc/srng)) (count coll))))) - (defn rand-bytes ^bytes [size] (let [ba (byte-array size)] (.nextBytes (enc/srng) ba) ba)) - (defn rand-double ^double [] (.nextDouble (enc/srng))) - (defn rand-gauss ^double [] (.nextGaussian (enc/srng))) - (defn rand-bool [] (.nextBoolean (enc/srng))) + (defn rand-nth [coll] (nth coll (int (* (.nextDouble (enc/secure-rng)) (count coll))))) + (defn rand-bytes ^bytes [size] (let [ba (byte-array size)] (.nextBytes (enc/secure-rng) ba) ba)) + (defn rand-double ^double [] (.nextDouble (enc/secure-rng))) + (defn rand-gauss ^double [] (.nextGaussian (enc/secure-rng))) + (defn rand-bool [] (.nextBoolean (enc/secure-rng))) (defn rand-long - (^long [ ] (.nextLong (enc/srng))) - (^long [n] (long (* (long n) (.nextDouble (enc/srng))))))) + (^long [ ] (.nextLong (enc/secure-rng))) + (^long [n] (long (* (long n) (.nextDouble (enc/secure-rng))))))) (comment (seq (rand-bytes 16)) diff --git a/src/taoensso/nippy/utils.clj b/src/taoensso/nippy/utils.clj index 95014f1..17ccd70 100644 --- a/src/taoensso/nippy/utils.clj +++ b/src/taoensso/nippy/utils.clj @@ -8,7 +8,7 @@ ;; Unfortunately the only ~reliable way we can tell if something's ;; really serializable/readable is to actually try a full roundtrip. -(let [swap-cache! @#'enc/-swap-cache!] ; TODO Public with newer Encore +(let [swap-cache! enc/-swap-val!] (defn- memoize-type-test [test-fn] (let [cache (atom {})] ; { } (fn [x]