taoensso / nippy

The fastest serialization library for Clojure
https://www.taoensso.com/nippy
Eclipse Public License 1.0
1.04k stars 60 forks source link

Fixes #128 - robust serialization for java.time.Instant #135

Closed cnuernber closed 3 years ago

cnuernber commented 3 years ago

We propose adding java-time as a simple extension namespace that first makes a version independent data structure out of the java.time object and then serializes to and from that ds to avoid java serialization version issues/conflicts.

solatis commented 3 years ago

I would appreciate this as well, it seems that thaw got a little more strict recently and we're getting "unthawable" errors for java.time.Instant.

To be precise:

{:nippy/unthawable
 {:cause :quarantined,
  :class-name "java.time.Instant",
  :content #<[B@238a7f2c>,
  :type :serializable}}
ptaoussanis commented 3 years ago

Will try to take care of this next weekend. Would ideally prefer to add to Nippy core, but that'd bump the minimum Java version to 8. Want to consider a little about how to approach.

@solatis In the meantime you can safely do something like the following:

(alter-var-root nippy/*thaw-serializable-allowlist*
  (fn [allowlist] (conj allowlist "java.time.Instant")))

This'll allow the use of Serializable for java.time.Instant.

ptaoussanis commented 3 years ago

Okay have added support, though via a different implementation that:

On Clojars now as [com.taoensso/nippy "3.1.0-RC1"].

Cheers!

harold commented 3 years ago

Hi, just tried this today ("3.1.0-RC1") and it worked in some simple cases, very grateful for this, thank you.

ptaoussanis commented 3 years ago

@harold Awesome, thanks for the confirmation- that helps!

harold commented 3 years ago

Yup, you're welcome.

Notably, files with instants that were serialized with 3.0.0 still load those instants as unthawable/quarantined - but I believe that's to be expected.

I re-serialized with 3.1.0-RC1 and everything (including some instants) round-tripped perfectly.