Skip to content

Commit

Permalink
[nop] Changes for dependency bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Sep 25, 2023
1 parent 7953751 commit e864294
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
4 changes: 3 additions & 1 deletion bb/graal_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
(let [graalvm-home (System/getenv "GRAALVM_HOME")
bin-dir (str (fs/file graalvm-home "bin"))]
(shell (executable bin-dir "gu") "install" "native-image")
(shell (executable bin-dir "native-image") "-jar" "target/graal-tests.jar" "--no-fallback" "graal_tests")))
(shell (executable bin-dir "native-image")
"--features=clj_easy.graal_build_time.InitClojureClasses"
"--no-fallback" "-jar" "target/graal-tests.jar" "graal_tests")))

(defn run-tests []
(let [{:keys [out]} (shell {:out :string} (executable "." "graal_tests"))]
Expand Down
16 changes: 8 additions & 8 deletions src/taoensso/nippy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
PersistentQueue PersistentTreeMap PersistentTreeSet PersistentList
LazySeq IRecord ISeq IType]))

(enc/assert-min-encore-version [3 58 0])
(enc/assert-min-encore-version [3 67 0])

(comment
(set! *unchecked-math* :warn-on-boxed)
Expand Down Expand Up @@ -471,17 +471,17 @@
(or
(when-let [s
(or
(do (enc/get-sys-val (get-in ids [action :base :prop]) (get-in ids [action :base :env])))
(when incl-legacy? (enc/get-sys-val (get-in ids [:legacy :base :prop]) (get-in ids [:legacy :base :env]))))]
(do (enc/get-sys-val* (get-in ids [action :base :prop]) (get-in ids [action :base :env])))
(when incl-legacy? (enc/get-sys-val* (get-in ids [:legacy :base :prop]) (get-in ids [:legacy :base :env]))))]

(if (allow-and-record? s) s (split-class-names>set s)))
default)

allowlist-add
(when-let [s
(or
(do (enc/get-sys-val (get-in ids [action :add :prop]) (get-in ids [action :add :env])))
(when incl-legacy? (enc/get-sys-val (get-in ids [:legacy :add :prop]) (get-in ids [:legacy :add :env]))))]
(do (enc/get-sys-val* (get-in ids [action :add :prop]) (get-in ids [action :add :env])))
(when incl-legacy? (enc/get-sys-val* (get-in ids [:legacy :add :prop]) (get-in ids [:legacy :add :env]))))]

(if (allow-and-record? s) s (split-class-names>set s)))]

Expand Down Expand Up @@ -547,8 +547,8 @@
Upgrading from an older version of Nippy and unsure whether you've been
using Nippy's Serializable support, or which classes to allow? See [2].
See also `taoensso.encore/compile-str-filter` for a util to help easily
build more advanced predicate functions.
See also `taoensso.encore/name-filter` for a util to help easily build
more advanced predicate functions.
Thanks to Timo Mihaljov (@solita-timo-mihaljov) for an excellent report
identifying this vulnerability.
Expand Down Expand Up @@ -649,7 +649,7 @@
(fn [x]
(if (allow-and-record? x)
allow-and-record-any-serializable-class-unsafe
(enc/compile-str-filter x))))
(enc/name-filter x))))

conform?* (fn [x cn] ((compile x) cn)) ; Uncached because input domain possibly infinite
conform?
Expand Down
24 changes: 12 additions & 12 deletions src/taoensso/nippy/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
;; 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-val!]
(defn- memoize-type-test [test-fn]
(let [cache (atom {})] ; {<type> <type-okay?>}
(fn [x]
(let [t (type x)
;; This is a bit hackish, but no other obvious solutions (?):
cacheable? (not (re-find #"__\d+" (str t))) ; gensym form
test (fn [] (try (test-fn x) (catch Exception _ false)))]
(if cacheable?
@(swap-cache! cache t #(if % % (delay (test))))
(test)))))))
(defn- memoize-type-test [test-fn]
(let [cache_ (enc/latom {})] ; {<type> <type-okay?>}
(fn [x]
(let [t (type x)
gensym? (re-find #"__\d+" (str t))
cacheable? (not gensym?) ; Hack, but no obviously better solutions
test (fn [] (try (test-fn x) (catch Exception _ false)))]

(if cacheable?
@(cache_ t #(if % % (delay (test))))
(do (test)))))))

(def readable? (memoize-type-test (fn [x] (-> x enc/pr-edn enc/read-edn) true)))
(def serializable?
Expand Down Expand Up @@ -53,7 +53,7 @@
(serializable? "Hello world") ; Cacheable
(readable? (fn [])) ; Uncacheable
(serializable? (fn [])) ; Uncacheable
)) ; [5.65 5.88 1129.46 1.4]
)) ; [2.52 2.53 521.34 0.63]

;;;;

Expand Down

0 comments on commit e864294

Please sign in to comment.