diff --git a/CHANGELOG.md b/CHANGELOG.md index 91a8a09..c68b9c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ > This project uses [Break Versioning](https://github.com/ptaoussanis/encore/blob/master/BREAK-VERSIONING.md) as of **Aug 16, 2014**. +## v2.9.0-RC3 / 2015 May 29 + +> This is a non-breaking **stability release** + +* **Implementation**: more robust error handling for unthawable records + +```clojure +[com.taoensso/nippy "2.9.0-RC3"] +``` + + ## v2.9.0-RC2 / 2015 May 6 > This is a non-breaking **performance release** diff --git a/README.md b/README.md index 12ef1dd..686c5f2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ```clojure [com.taoensso/nippy "2.8.0"] ; Stable -[com.taoensso/nippy "2.9.0-RC2"] ; Dev, please see CHANGELOG for details +[com.taoensso/nippy "2.9.0-RC3"] ; Dev, please see CHANGELOG for details ``` # Nippy, a Clojure serialization library diff --git a/project.clj b/project.clj index 78e5096..9b3ec96 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject com.taoensso/nippy "2.9.0-RC2" +(defproject com.taoensso/nippy "2.9.0-RC3" :author "Peter Taoussanis " :description "Clojure serialization library" :url "https://github.com/ptaoussanis/nippy" @@ -14,7 +14,7 @@ :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/tools.reader "0.9.2"] - [com.taoensso/encore "1.28.0"] + [com.taoensso/encore "1.32.0"] [org.iq80.snappy/snappy "0.3"] [org.tukaani/xz "1.5"] [net.jpountz.lz4/lz4 "1.3"]] diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index e825440..c0f01ec 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -461,6 +461,7 @@ (encore/repeatedly-into* ~coll (quot (.readInt in#) 2) [(thaw-from-in in#) (thaw-from-in in#)]))) +(def ^:private class-method-sig (into-array Class [IPersistentMap])) (declare ^:private custom-readers) (defn- read-custom! [type-id in] @@ -489,21 +490,40 @@ id-reader (let [edn (read-utf8 in)] - (try (edn/read-string {:readers *data-readers*} edn) - (catch Exception e {:nippy/unthawable edn - :type :reader - :throwable e}))) + (try + (edn/read-string {:readers *data-readers*} edn) + (catch Exception e + {:type :reader + :throwable e + :nippy/unthawable edn}))) id-serializable (let [class-name (read-utf8 in)] - (try (let [;; .readObject _before_ Class/forName: it'll always read - ;; all data before throwing - object (.readObject (ObjectInputStream. in)) - ^Class class (Class/forName class-name)] - (cast class object)) - (catch Exception e {:nippy/unthawable class-name - :type :serializable - :throwable e}))) + (try + (let [content (.readObject (ObjectInputStream. in))] + (try + (let [class (Class/forName class-name)] + (cast class content)) + (catch Exception e + {:type :serializable + :throwable e + :nippy/unthawable {:class-name class-name :content content}}))) + (catch Exception e + {:type :serializable + :throwable e + :nippy/unthawable {:class-name class-name :content nil}}))) + + id-record + (let [class-name (read-utf8 in) + content (thaw-from-in in)] + (try + (let [class (Class/forName class-name) + method (.getMethod class "create" class-method-sig)] + (.invoke method class (into-array Object [content]))) + (catch Exception e + {:type :record + :throwable e + :nippy/unthawable {:class-name class-name :content content}}))) id-bytes (read-bytes in) id-nil nil @@ -552,12 +572,6 @@ id-ratio (/ (bigint (read-biginteger in)) (bigint (read-biginteger in))) - id-record - (let [class ^Class (Class/forName (read-utf8 in)) - meth-sig (into-array Class [IPersistentMap]) - method ^Method (.getMethod class "create" meth-sig)] - (.invoke method class (into-array Object [(thaw-from-in in)]))) - id-date (Date. (.readLong in)) id-uuid (UUID. (.readLong in) (.readLong in))