tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

start-with generating TimSort NPE when passed a pre-defined map #117

Closed Activeghost closed 4 years ago

Activeghost commented 4 years ago

I'm trying to get a generic "start any set of mocks" (in this case generating that list by easy to remember keywords) and I'm running into a NPE from TimSort when calling (mount/start-with ...). Since start-with isn't a macro I'm at a loss for why where mocks is basically just the map in a def instead of defined .

original code (works):

(defn start-system [rds-mock redis-mock]
  (let [mocks (get-mock-fns rds-mock redis-mock)]
    (mount/start-with {#'save-full-content-lua! (:save-full-content-lua mocks)
                       #'read-from-mysql!       (:read-from-mysql mocks)
                       #'save-to-mysql!         (:save-to-mysql mocks)
                       #'read-from-redis!       (:read-from-redis mocks)
                       #'save-to-redis!         (:save-to-redis mocks)})))

Repro:

(def the-mocks {#'save-full-content-lua! (fn [] "some fn")
                #'read-from-mysql!       (fn [] "some fn")
                #'save-to-mysql!         (fn [] "some fn")
                #'read-from-redis!       (fn [] "some fn")
                #'save-to-redis!         (fn [] "some fn")})
#'v2-storage-proxy.mock-system/the-mocks

=>(mount/start-with the-mocks)
Execution error (NullPointerException) at java.util.TimSort/binarySort (TimSort.java:296).
null
class java.lang.NullPointerException
Activeghost commented 4 years ago

Actually, getting the same error with the original now. This is probably environmental (yay). Thx.

Activeghost commented 4 years ago

Turned out to be Calva's repl.