Welcome! Please see the About page for a little more info on how this works.

+1 vote
in REPL by

In a prepl session, Clojure warnings remain buffered and won't be sent to the client without flushing explicitly from the client side.

Here is an example prepl session using netcat (the lines starting with ;; indicate responses from the prepl server):

$ clojure -X clojure.core.server/start-server :name prepl :port 5555 :accept clojure.core.server/io-prepl :server-daemon false &
$ nc localhost 5555

(set! *warn-on-reflection* true)
;; {:tag :ret, :val "true", :ns "user", :ms 2, :form "(set! *warn-on-reflection* true)"}

(.toString (identity "foo"))
;; {:tag :ret, :val "\"foo\"", :ns "user", :ms 4, :form "(.toString (identity \"foo\"))"}
(binding [*out* *err*] (flush))
;; {:tag :err, :val "Reflection warning, NO_SOURCE_PATH:2:1 - reference to field toString can't be resolved.\n"}
;; {:tag :ret, :val "nil", :ns "user", :ms 4, :form "(binding [*out* *err*] (flush))"}

(defn identity [x] x)
;; {:tag :ret, :val "#'user/identity", :ns "user", :ms 3, :form "(defn identity [x] x)"}
(binding [*out* *err*] (flush))
;; {:tag :err, :val "WARNING: identity already refers to: #'clojure.core/identity in namespace: user, being replaced by: #'user/identity\n"}
;; {:tag :ret, :val "nil", :ns "user", :ms 2, :form "(binding [*out* *err*] (flush))"}

This seems to be caused by the fact that prepl's *err* PrintWriter is not autoFlush-enabled and that most of the Clojure warnings are not flushed explicitly.

Is this an issue to be addressed? Or is it an intended behavior and it's the client's responsibility to flush the error stream on a timely basis?

1 Answer

0 votes

This issue seems to have been filed to JIRA as CLJ-2645.