Hi component friends. I just got an interesting stacktrace from a component usage to which I’m not sure the best way to respond.
In this app, I’m running a persistent system that would like to be able to shutdown cleanly when it receives a SIGTERM. The bootup is, in essence:
(defn -main
[]
(let [system (volatile! (system/create-system))
runtime (Runtime/getRuntime)
shutdown? (promise)]
(.addShutdownHook runtime
(Thread. (fn []
(component/stop-system @system)
(deliver shutdown? true))))
(vswap! system component/start-system)
@shutdown?))
It… usually works as I expect, but once I got this:
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: com/stuartsierra/component$update_system_reverse$fn__1373
at com.stuartsierra.component$update_system_reverse.invokeStatic(component.cljc:143)
at com.stuartsierra.component$update_system_reverse.doInvoke(component.cljc:143)
at clojure.lang.RestFn.invoke(RestFn.java:445)
at com.stuartsierra.component$stop_system.invokeStatic(component.cljc:173)
at com.stuartsierra.component$stop_system.invoke(component.cljc:165)
at com.stuartsierra.component$stop_system.invokeStatic(component.cljc:171)
at bleach.system$stop.invokeStatic(system.clj:177)
at bleach.main$fn__6067$fn__6068.invoke(main.clj:94)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.stuartsierra.component$update_system_reverse$fn__1373
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
Which I presume indicates a race between the classloader disposing things and the shutdown hook being invoked
I would appreciate any thoughts on how to work around or better implement this
I would very much doubt that
my guess would be either some kind of weird aot thing or some kind of weird reloaded thing