thaw API should throw on first non-legacy error
This commit is contained in:
parent
a2cdfba874
commit
9a2b0a068b
3 changed files with 11 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ Current [semantic](http://semver.org/) version:
|
|||
|
||||
```clojure
|
||||
[com.taoensso/nippy "1.2.1"] ; Stable
|
||||
[com.taoensso/nippy "2.0.0-alpha9"] ; Development (notes below)
|
||||
[com.taoensso/nippy "2.0.0-alpha10"] ; Development (notes below)
|
||||
```
|
||||
|
||||
v2 adds pluggable compression, crypto support (also pluggable), an improved API (including much better error messages), easier integration into other tools/libraries, and hugely improved performance. It **is backwards compatible**, but please note that the old `freeze-to-bytes`/`thaw-from-bytes` API has been **deprecated** in favor of `freeze`/`thaw`. **PLEASE REPORT ANY PROBLEMS!**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
(defproject com.taoensso/nippy "2.0.0-alpha9"
|
||||
(defproject com.taoensso/nippy "2.0.0-alpha10"
|
||||
:description "Clojure serialization library"
|
||||
:url "https://github.com/ptaoussanis/nippy"
|
||||
:license {:name "Eclipse Public License"
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@
|
|||
(if-let [[data-ba {:keys [unrecognized-header? compressed? encrypted?]
|
||||
:as head-meta}] (try-parse-header ba)]
|
||||
|
||||
(cond ; Header appears okay
|
||||
(cond ; Header _appears_ okay
|
||||
(and (not legacy-opts) unrecognized-header?) ; Conservative
|
||||
(ex "Unrecognized header. Data frozen with newer Nippy version?")
|
||||
(and compressed? (not compressor))
|
||||
|
|
@ -305,10 +305,15 @@
|
|||
(if (::tools-thaw? opts) ::need-password
|
||||
(ex "Encrypted data. Try again with password."))
|
||||
:else (try (try-thaw-data data-ba head-meta)
|
||||
(catch Exception _ (try-thaw-data ba nil))))
|
||||
(catch Exception e
|
||||
(if legacy-opts
|
||||
(try-thaw-data ba nil)
|
||||
(throw e)))))
|
||||
|
||||
;; Header definitely not okay
|
||||
(try-thaw-data ba nil))))
|
||||
(if legacy-opts
|
||||
(try-thaw-data ba nil)
|
||||
(ex "Unfrozen or corrupt data?")))))
|
||||
|
||||
(comment (thaw (freeze "hello"))
|
||||
(thaw (freeze "hello" {:compressor nil}))
|
||||
|
|
|
|||
Loading…
Reference in a new issue