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

Protocols on thawed records fail #60

Closed optevo closed 9 years ago

optevo commented 9 years ago

(defprotocol ISample (greet [_]))

(defrecord Sample [x] ISample (greet [_](str "g'day " x)))

(def s (Sample. "mate"))

(greet s)

(def e (thaw (freeze s)))

(greet e)

The thawed version fails with java.lang.IllegalArgumentException: No implementation of method: :greet of protocol: #'easy.scratch/ISample found for class: easy.scratch.Sample

ptaoussanis commented 9 years ago

Hi Richard,

This works on my end, but only for the first class definitions. If you redefine the protocol/record (e.g. during REPL development), then things go wonky. I believe this is related to http://dev.clojure.org/jira/browse/CLJ-979 (which has recently been marked as fixed for Clojure 1.7).

So what you're doing should work fine in production, but may behave unpredictably during development if you're at a REPL.

Does that help?

optevo commented 9 years ago

Thanks for that.

Just upgraded from 1.7.0-alpha4 to 1.7.0-alpha5

It works fine in a REPL (I didn't try that before although I should have) but gives the same error in Lighttable. Happy for this bug to be closed as it's not a bug in Nippy.

ptaoussanis commented 9 years ago

Great, thanks for the follow-up. Cheers! :-)