[fix] [#143] Don't freeze meta info for types that don't support with-meta
This commit is contained in:
parent
aba153e086
commit
fa1cc66bf3
2 changed files with 10 additions and 3 deletions
|
|
@ -630,9 +630,9 @@
|
|||
(defprotocol IFreezable1 (-freeze-without-meta! [x data-output]))
|
||||
(defprotocol IFreezable2 (-freeze-with-meta! [x data-output]))
|
||||
(extend-protocol IFreezable2 ; Must be a separate protocol
|
||||
clojure.lang.IMeta
|
||||
clojure.lang.IObj ; IMeta => `meta` will work, IObj => `with-meta` will work
|
||||
(-freeze-with-meta! [x ^DataOutput data-output]
|
||||
(let [m (when *incl-metadata?* (.meta x))]
|
||||
(let [m (when *incl-metadata?* (meta x))]
|
||||
(when m
|
||||
(write-id data-output id-meta)
|
||||
(-freeze-without-meta! m data-output)))
|
||||
|
|
|
|||
|
|
@ -326,6 +326,8 @@
|
|||
|
||||
;;;; Metadata
|
||||
|
||||
(def my-var "Just a string")
|
||||
|
||||
(deftest _metadata
|
||||
[(is
|
||||
(:has-meta?
|
||||
|
|
@ -355,7 +357,12 @@
|
|||
{:incl-metadata? true}
|
||||
)))
|
||||
|
||||
"Metadata successfully excluded by freeze")])
|
||||
"Metadata successfully excluded by freeze")
|
||||
|
||||
(is (var? (nippy/read-quarantined-serializable-object-unsafe!
|
||||
(nippy/thaw (nippy/freeze #'my-var))))
|
||||
|
||||
"Don't try to preserve metadata on vars")])
|
||||
|
||||
;;;; Benchmarks
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue