diff --git a/src/taoensso/nippy.clj b/src/taoensso/nippy.clj index 57c13df..c0f01ec 100644 --- a/src/taoensso/nippy.clj +++ b/src/taoensso/nippy.clj @@ -490,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 @@ -553,19 +572,6 @@ id-ratio (/ (bigint (read-biginteger in)) (bigint (read-biginteger in))) - 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 - {:nippy/unthawable class-name - :type :record - :content content - :throwable e}))) - id-date (Date. (.readLong in)) id-uuid (UUID. (.readLong in) (.readLong in))