Permalink
Browse files

Eliminate potential memory leak from jline logger

  • Loading branch information...
1 parent 2e95393 commit 708a23b27109c785f5fe1044fc045142f91f325f @trptcolin committed Apr 7, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/clj/reply/reader/simple_jline.clj
@@ -22,15 +22,18 @@
(.restore (.getTerminal reader))
(.shutdown reader)))
+(defn null-output-stream []
+ (proxy [java.io.OutputStream] []
+ (write [b])))
+
(defn- initialize-jline []
(.addShutdownHook (Runtime/getRuntime)
(Thread. #(when-let [reader @current-console-reader]
(shutdown reader))))
(when (= "dumb" (System/getenv "TERM"))
(.setProperty (Configuration/getProperties) "jline.terminal" "none"))
- ;; TODO: what happens when nobody consumes from this stream?
(when-not (System/getenv "JLINE_LOGGING")
- (Log/setOutput (PrintStream. (ByteArrayOutputStream.)))))
+ (Log/setOutput (PrintStream. (null-output-stream)))))
(defn- prepare-for-next-read [{:keys [reader] :as state}]
(.flush (.getHistory reader))

0 comments on commit 708a23b

Please sign in to comment.