magnars / optimus

A Ring middleware for frontend performance optimization.
364 stars 23 forks source link

optimus.strategies/serve-live-assets-autorefresh triggers NullPointerException #42

Closed zane closed 7 years ago

zane commented 9 years ago

Attempting to call optimus.prime/wrap with optimus.strategies/serve-live-assets-autorefresh is triggering a NullPointerException for me. It looks like it's having trouble resolving 'watch-dir on this line: https://github.com/magnars/optimus/blob/master/src/optimus/strategies.clj#L52

> (optimus.homeless/jdk-version)
1.8
> (clojure-version)
"1.7.0"
magnars commented 9 years ago

Thanks for the report! Looks like the conditional use shenanigans is biting us. @env0der, do you have a moment to take a look at this?

In the meantime, I can only point you to serve-live-assets - that's what I'm using.

magnars commented 9 years ago

@env0der I combined the two jdk-version checks into a single do in this commit - maybe that change broke it? I have very little experience with dynamically requiring things during the runtime. Meaning none. :)

antonyshchenko commented 9 years ago

@magnars, yes looks like it was caused by that commit. I also don't have much experience with dynamic requires in clojure runtime. I've just hacked it and it somehow worked :) Try reverting it.

magnars commented 9 years ago

@env0der I am unable to get this working. Even with [juxt.dirwatch :refer [watch-dir]] added to the namespace in a regular fashion, it still fails with a NullPointerException at the deref:

(@(resolve 'watch-dir) on-assets-changed assets-dir)

It seems to work in the REPL tho. Maybe this fails only when served from .m2? I guess it works for you - how do you use it?

antonyshchenko commented 9 years ago

@magnars I did not check it after it was merged. The project where it was used was over for me at that time already. When I was using it, it was implemented in my clojure app as a couple of modified functions from optimus + my additional strategy function.

I will investigate the problem on the weekend.

karneaud commented 8 years ago

+1 to have this fixed....I use the latest version and get this error!

magnars commented 8 years ago

I'll take a look at it today. fre. 22. jul. 2016 kl. 05.42 skrev karneaud notifications@github.com:

+1 to have this fixed....I use the latest version and get this error!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magnars/optimus/issues/42#issuecomment-234447547, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQOOW_CnfUtDHiduL9DUlBvgD5lVEMBks5qYDxCgaJpZM4Fpq_g .

magnars commented 8 years ago

I have now released 0.19.0 which hopefully fixes this issue. I've removed the quirky use shenanigans in favor of plain-old-requires. In doing so I had to ditch support for JDK 1.6 and below, following suit with Clojure.

Please let me know if this fixes your issue.