We're updating the issue view to help you get more done. 

Socket server can't use user-defined accept-fns

Description

In 1.8.0 RC2, if you start a socket server with a user-defined accept-fn like the following (clojure.test/testing-contexts-str is just a 0-arity fn used as an example accept fn here):

1 $ java -cp clojure-1.8.0-RC2.jar -Dclojure.server.foo='{:port 5555 :accept clojure.test/testing-contexts-str}' clojure.main

And then, if you connect to it with a command like "telnet 127.0.0.1 5555", you'll get an NPE.

1 2 3 4 5 6 7 Clojure 1.8.0-RC2 user=> Exception in thread "Clojure Connection repl 1" java.lang.NullPointerException at clojure.core$apply.invokeStatic(core.clj:645) at clojure.core.server$accept_connection.invokeStatic(server.clj:60) at clojure.core.server$start_server$fn__7327$fn__7328$fn__7330.invoke(server.clj:104) at clojure.lang.AFn.run(AFn.java:22) at java.lang.Thread.run(Thread.java:745)

This doesn't happen when starting the server with a pre-defined accept-fn, such as clojure.core.server/repl.

Cause: At the moment, clojure.core.server/accept-connection will require the namespace in which the accept-fn is defined after resolving the accept-fn. However, in order to resolve the accept-fn successfully, requiring the ns should be done prior to it.

Approach: Requiring the ns before resolving the accept-fn.

Patch: 0001-CLJ-1853-Require-the-ns-before-resolving-the-accept-.patch

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

Shogo Ohta

Labels

Approval

Ok

Patch

Code

Fix versions

Affects versions

Release 1.8

Priority

Major