Warn about thaw-id reset at runtime rather than expansion time
This commit is contained in:
parent
82294f54f9
commit
5a623870fe
1 changed files with 15 additions and 13 deletions
|
|
@ -768,17 +768,19 @@
|
||||||
(->MyType (.readUTF data-input)))"
|
(->MyType (.readUTF data-input)))"
|
||||||
[custom-type-id [in] & body]
|
[custom-type-id [in] & body]
|
||||||
(assert-custom-type-id custom-type-id)
|
(assert-custom-type-id custom-type-id)
|
||||||
(when (contains? *custom-readers* (coerce-custom-type-id custom-type-id))
|
`(do
|
||||||
|
(when (contains? *custom-readers* ~(coerce-custom-type-id custom-type-id))
|
||||||
(println (format "Warning: resetting Nippy thaw for custom type with id: %s"
|
(println (format "Warning: resetting Nippy thaw for custom type with id: %s"
|
||||||
custom-type-id)))
|
~custom-type-id)))
|
||||||
`(swap-custom-readers!
|
(swap-custom-readers!
|
||||||
(fn [m#]
|
(fn [m#]
|
||||||
(assoc m#
|
(assoc m#
|
||||||
~(coerce-custom-type-id custom-type-id)
|
~(coerce-custom-type-id custom-type-id)
|
||||||
(fn [~(with-meta in {:tag 'java.io.DataInput})]
|
(fn [~(with-meta in {:tag 'java.io.DataInput})]
|
||||||
~@body)))))
|
~@body))))))
|
||||||
|
|
||||||
(comment (defrecord MyType [data])
|
(comment
|
||||||
|
(defrecord MyType [data])
|
||||||
(extend-freeze MyType 1 [x out] (.writeUTF out (:data x)))
|
(extend-freeze MyType 1 [x out] (.writeUTF out (:data x)))
|
||||||
(extend-thaw 1 [in] (->MyType (.readUTF in)))
|
(extend-thaw 1 [in] (->MyType (.readUTF in)))
|
||||||
(thaw (freeze (->MyType "Joe"))))
|
(thaw (freeze (->MyType "Joe"))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue