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

Can this work without `getClassLoader`? #85

Closed jeaye closed 7 years ago

jeaye commented 7 years ago

getClassLoader is apparently not allowed on Google App Engine, where I'd love to run nippy to interface with my datastore. Unfortunately, I get run-time permission errors along the lines of:

Caused by: java.security.AccessControlException:
access denied ("java.lang.RuntimePermission" "getClassLoader") at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:484) at
java.security.AccessController.checkPermission(AccessController.java:698) at
java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at
java.lang.ClassLoader.checkClassLoaderPermission(ClassLoader.java:1609) at
java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1528) at
net.jpountz.lz4.LZ4Factory.fastestInstance(LZ4Factory.java:135) at
taoensso.nippy.compression__init.load(Unknown Source) at
taoensso.nippy.compression__init.<clinit>(Unknown Source)

Thanks for the awesome Clojure projects.

ptaoussanis commented 7 years ago

Hi there, sorry - not familiar with Google App Engine so can't make a recommendation offhand.

jeaye commented 7 years ago

It looks like nippy is using LZ4Factory to compress, which uses getClassLoader. Is there a way to use nippy which doesn't compress, or compresses using something which doesn't use getClassLoader?

ptaoussanis commented 7 years ago

It is possible to use different compressors and/or no compression, please see the docs for details.

Not sure if this'll help in your case though assuming it's a compile-time dependency error?

On Aug 30, 2016 00:05, "jeaye" notifications@github.com wrote:

It looks like nippy is using LZ4Factory to compress, which uses getClassLoader. Is there a way to use nippy which doesn't compress, or compresses using something which doesn't use getClassLoader?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ptaoussanis/nippy/issues/85#issuecomment-243186458, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJxC2T8RVHnPFKidxv76ibAK04vbY0Hks5qkxFTgaJpZM4JvC8v .

jeaye commented 7 years ago

Not sure if this'll help in your case though assuming it's a compile-time dependency error?

No, this is a run-time error which happens when I try to freeze data using nippy's default configuration. Google App Engine prevents the usage of getClassLoader, among other things, at run-time. Disabling compression would likely do the trick.

ptaoussanis commented 7 years ago

Great, then disabling compression should do the trick.

On Aug 30, 2016 10:33, "jeaye" notifications@github.com wrote:

Not sure if this'll help in your case though assuming it's a compile-time dependency error?

No, this is a run-time error which happens when I try to freeze data using nippy's default configuration. Google App Engine prevents the usage of getClassLoader, among other things, at run-time. Disabling compression would likely do the trick.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ptaoussanis/nippy/issues/85#issuecomment-243323634, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJxCxdS5skEwVCUs698VQzony1wnA0Wks5qk6R4gaJpZM4JvC8v .

jeaye commented 7 years ago

Bah, after further inspection this happens on load, at run-time, because of this: https://github.com/ptaoussanis/nippy/blob/master/src/taoensso/nippy/compression.clj#L101 Even if I don't enable encryption or compression, this def is evaluated on load. Ideally, there's a compile-time flag for this or the LZ4Factory isn't created until it's needed.

Can you see a way in which you'd be willing to support this?

ptaoussanis commented 7 years ago

Happy to consider a PR, otherwise will need a few weeks to be able to look at this myself.

First step will be confirming that this is the only thing stopping use on GAE.

Cheers

On Aug 30, 2016 11:37 AM, "jeaye" notifications@github.com wrote:

Bah, after further inspection this happens on load, at run-time, because of this: https://github.com/ptaoussanis/nippy/blob/master/ src/taoensso/nippy/compression.clj#L101 Even if I don't enable encryption or compression, this def is evaluated on load. Ideally, there's a compile-time flag for this or the LZ4Factory isn't created until it's needed.

Can you see a way in which you'd be willing to support this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ptaoussanis/nippy/issues/85#issuecomment-243330931, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJxC1mGyTZ3yMfhPhny8s7tZAv3Va3gks5qk7OYgaJpZM4JvC8v .

mpenet commented 7 years ago

Just wrapping this global in a c.c/delay should fix that, no?

ptaoussanis commented 7 years ago

Should do, just have my hands full with other priorities atm- PR welcome with confirmation that that's the only sticking issue for GAE.

jeaye commented 7 years ago

On Tue, Aug 30, 2016 at 03:05:06AM -0700, Max Penet wrote:

Just wrapping this global in a c.c/delay should fix that, no?

delay does the trick, for sure; that, combined with some workarounds for tufte and I'm running on GAE now. I'll follow up with a PR.

ptaoussanis commented 7 years ago

Fix merged, thanks.

jeaye commented 7 years ago

Can we get a new version of this on clojars so I can stop using my fork? Thanks very much. 🙇

ptaoussanis commented 7 years ago

Sure, just pushed [com.taoensso/nippy "2.12.3-alpha1"] to Clojars.

jeaye commented 7 years ago

Thanks!

ptaoussanis commented 7 years ago

No problem :-)