Add option to disable v1 thaw compatibility
This commit is contained in:
parent
f1b4c7ff88
commit
26c01c799a
1 changed files with 15 additions and 8 deletions
|
|
@ -565,10 +565,13 @@
|
||||||
Options include:
|
Options include:
|
||||||
:compressor - An ICompressor, :auto (requires Nippy header), or nil.
|
:compressor - An ICompressor, :auto (requires Nippy header), or nil.
|
||||||
:encryptor - An IEncryptor, :auto (requires Nippy header), or nil."
|
:encryptor - An IEncryptor, :auto (requires Nippy header), or nil."
|
||||||
[^bytes ba & [{:keys [compressor encryptor password]
|
[^bytes ba
|
||||||
:or {compressor :auto
|
& [{:keys [compressor encryptor password v1-compatibility?]
|
||||||
encryptor :auto}
|
:or {compressor :auto
|
||||||
:as opts}]]
|
encryptor :auto
|
||||||
|
v1-compatibility? true ; Recommend disabling when possible
|
||||||
|
}
|
||||||
|
:as opts}]]
|
||||||
|
|
||||||
(assert (not (contains? opts :headerless-meta))
|
(assert (not (contains? opts :headerless-meta))
|
||||||
":headerless-meta `thaw` option removed as of Nippy v2.7.")
|
":headerless-meta `thaw` option removed as of Nippy v2.7.")
|
||||||
|
|
@ -598,11 +601,15 @@
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(ex "Decryption/decompression failure, or data unfrozen/damaged.")))))
|
(ex "Decryption/decompression failure, or data unfrozen/damaged.")))))
|
||||||
|
|
||||||
thaw-nippy-v1-data ; A little hackish, but necessary
|
;; This is hackish and can actually currently result in JVM core dumps
|
||||||
|
;; due to buggy Snappy behaviour, Ref. http://goo.gl/mh7Rpy.
|
||||||
|
thaw-nippy-v1-data
|
||||||
(fn [data-ba]
|
(fn [data-ba]
|
||||||
(try (thaw-data data-ba :snappy nil)
|
(if-not v1-compatibility?
|
||||||
(catch Exception _
|
(throw (Exception. "v1 compatibility disabled"))
|
||||||
(thaw-data data-ba nil nil))))]
|
(try (thaw-data data-ba :snappy nil)
|
||||||
|
(catch Exception _
|
||||||
|
(thaw-data data-ba nil nil)))))]
|
||||||
|
|
||||||
(if-let [[data-ba {:keys [compressor-id encryptor-id unrecognized-meta?]
|
(if-let [[data-ba {:keys [compressor-id encryptor-id unrecognized-meta?]
|
||||||
:as head-meta}] (try-parse-header ba)]
|
:as head-meta}] (try-parse-header ba)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue