{"action":"created","issue":{"url":"https://api.github.com/repos/ztellman/manifold/issues/42","labels_url":"https://api.github.com/repos/ztellman/manifold/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/ztellman/manifold/issues/42/comments","events_url":"https://api.github.com/repos/ztellman/manifold/issues/42/events","html_url":"https://github.com/ztellman/manifold/issues/42","id":96628894,"number":42,"title":"NPE in graph when websocket stream disconnects","user":{"login":"ddossot","id":119028,"avatar_url":"https://avatars.githubusercontent.com/u/119028?v=3","gravatar_id":"","url":"https://api.github.com/users/ddossot","html_url":"https://github.com/ddossot","followers_url":"https://api.github.com/users/ddossot/followers","following_url":"https://api.github.com/users/ddossot/following{/other_user}","gists_url":"https://api.github.com/users/ddossot/gists{/gist_id}","starred_url":"https://api.github.com/users/ddossot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddossot/subscriptions","organizations_url":"https://api.github.com/users/ddossot/orgs","repos_url":"https://api.github.com/users/ddossot/repos","events_url":"https://api.github.com/users/ddossot/events{/privacy}","received_events_url":"https://api.github.com/users/ddossot/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-22T18:02:20Z","updated_at":"2015-07-22T21:29:50Z","closed_at":"2015-07-22T21:29:50Z","body":"Using `Aleph 0.4.1-alpha1` and `Manifold 0.1.1-alpha2`.\r\n\r\nHere is the code that connects a `socket` stream to a `bus` subscription stream:\r\n\r\n```clojure\r\n  (s/connect\r\n    (s/filter\r\n      (partial\r\n        room-accept-event?\r\n        idempotent-filter)\r\n      (bus/subscribe\r\n        chatrooms room))\r\n    socket)\r\n```\r\n\r\nThe filter fn is:\r\n```clojure\r\n(defn- room-accept-event?\r\n  [idempotent-filter event]\r\n  (or\r\n    (nil? event)\r\n    (not (.add idempotent-filter event :ignored))))\r\n```\r\n`idempotent-filter` is a non-nil-safe bounded FIFO map, we accept `nil` values because we think it's the proper indicator of a drained source and want to pass it to the sink.\r\n\r\nWhen a browser window gets brutally closed, the following NPE shows up in the log:\r\n<pre>\r\n[manifold-scheduler-pool-1] 2015-07-22 10:39:54,626 ERROR [manifold.deferred] error in deferred handler\r\njava.lang.NullPointerException\r\n\tat manifold.stream.graph$async_connect$this__6562.invoke(graph.clj:183)\r\n\tat manifold.stream.graph$async_connect$this__6562$fn__6563$fn__6564.invoke(graph.clj:162)\r\n\tat clojure.core$trampoline.invoke(core.clj:6037)\r\n\tat manifold.stream.graph$async_connect$this__6562$fn__6563.invoke(graph.clj:162)\r\n\tat manifold.deferred.Listener.onSuccess(deferred.clj:219)\r\n\tat manifold.deferred.Deferred$fn__6019.invoke(deferred.clj:398)\r\n\tat manifold.deferred.Deferred.success(deferred.clj:398)\r\n\tat manifold.deferred$success_BANG_.invoke(deferred.clj:245)\r\n\tat manifold.stream.default.Stream.put(default.clj:119)\r\n\tat manifold.stream.default.Stream.put(default.clj:141)\r\n\tat manifold.stream$filter$fn__7154.invoke(stream.clj:628)\r\n\tat manifold.stream.Callback.put(stream.clj:452)\r\n\tat manifold.stream.graph$async_send.invoke(graph.clj:50)\r\n\tat manifold.stream.graph$async_connect$this__6562.invoke(graph.clj:181)\r\n\tat manifold.stream.graph$async_connect$this__6562$fn__6563$fn__6564.invoke(graph.clj:162)\r\n\tat clojure.core$trampoline.invoke(core.clj:6037)\r\n\tat manifold.stream.graph$async_connect$this__6562$fn__6563.invoke(graph.clj:162)\r\n\tat manifold.deferred.Listener.onSuccess(deferred.clj:219)\r\n\tat manifold.deferred.Deferred$fn__6019.invoke(deferred.clj:398)\r\n\tat manifold.deferred.Deferred.success(deferred.clj:398)\r\n\tat manifold.deferred$success_BANG_.invoke(deferred.clj:245)\r\n\tat manifold.stream.default.Stream.put(default.clj:119)\r\n\tat manifold.stream.default.Stream.put(default.clj:141)\r\n\tat manifold.bus$event_bus$reify__9469$fn__9472.invoke(bus.clj:110)\r\n\tat clojure.core$map$fn__4553.invoke(core.clj:2624)\r\n\tat clojure.lang.LazySeq.sval(LazySeq.java:40)\r\n\tat clojure.lang.LazySeq.seq(LazySeq.java:49)\r\n\tat clojure.lang.RT.seq(RT.java:507)\r\n\tat clojure.core$seq__4128.invoke(core.clj:137)\r\n\tat clojure.core$apply.invoke(core.clj:630)\r\n\tat manifold.bus$event_bus$reify__9469.publish(bus.clj:110)\r\n\tat com.unbounce.events_gateway.server_push$broadcast_heartbeat.invoke(server_push.clj:325)\r\n\tat com.unbounce.events_gateway.server_push$make_heartbeater$_heartbeater__11697.invoke(server_push.clj:339)\r\n\tat manifold.time$fn__5771$every__5780$f__5781.invoke(time.clj:169)\r\n\tat clojure.lang.AFn.run(AFn.java:22)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\r\n\tat java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)\r\n\tat java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)\r\n\tat java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat manifold.executor$thread_factory$reify__5598$f__5599.invoke(executor.clj:36)\r\n\tat clojure.lang.AFn.run(AFn.java:22)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n</pre>\r\nIt happens a few times per closed socket, when `put`s are attempted. Then things clear up internally and the NPE doesn't happen any more."},"comment":{"url":"https://api.github.com/repos/ztellman/manifold/issues/comments/123872515","html_url":"https://github.com/ztellman/manifold/issues/42#issuecomment-123872515","issue_url":"https://api.github.com/repos/ztellman/manifold/issues/42","id":123872515,"user":{"login":"ddossot","id":119028,"avatar_url":"https://avatars.githubusercontent.com/u/119028?v=3","gravatar_id":"","url":"https://api.github.com/users/ddossot","html_url":"https://github.com/ddossot","followers_url":"https://api.github.com/users/ddossot/followers","following_url":"https://api.github.com/users/ddossot/following{/other_user}","gists_url":"https://api.github.com/users/ddossot/gists{/gist_id}","starred_url":"https://api.github.com/users/ddossot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddossot/subscriptions","organizations_url":"https://api.github.com/users/ddossot/orgs","repos_url":"https://api.github.com/users/ddossot/repos","events_url":"https://api.github.com/users/ddossot/events{/privacy}","received_events_url":"https://api.github.com/users/ddossot/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T21:29:50Z","updated_at":"2015-07-22T21:29:50Z","body":"Confirmed! I've tried a locally built `[aleph \"0.4.1-SNAPSHOT\"]` with this fix in and the problem is gone.\r\n\r\nThanks a lot."}}