Skip to content

Instantly share code, notes, and snippets.

@shepmaster shepmaster/Backtrace
Created Sep 17, 2011

Embed
What would you like to do?
$ java -cp clojure.jar clojure.main ~/Projects/Clojure/fake-cs.clj
Sending...
#<Agent@1f758500: {:name Music, :online false}>
Starting...
Exception in thread "main" java.lang.NullPointerException (fake-cs.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.load(Compiler.java:5857)
at clojure.lang.Compiler.loadFile(Compiler.java:5820)
at clojure.main$load_script.invoke(main.clj:221)
at clojure.main$script_opt.invoke(main.clj:273)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:365)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
at user$eval2$send_start__3.invoke(fake-cs.clj:16)
at user$eval2.invoke(fake-cs.clj:17)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 10 more
(def my-service (agent {:name "Music" :online false}))
(defn bring-online [service]
(cond
(service :online) (do
(println "Already started...")
service)
:else (do
(println "Starting...")
(.. Thread (sleep 1000))
(assoc service :online (not (service :online))))))
(let [send-start #((println "Sending...")
(println my-service)
(println)
(send my-service bring-online))]
(send-start)
(send-start))
(shutdown-agents)
(println @my-service)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.