File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change 7
7
[clojure.java.io :as io]
8
8
[clojure.string :as string])
9
9
(:import
10
- (java.io EOFException InputStream OutputStream)))
10
+ (java.io
11
+ EOFException
12
+ IOException
13
+ InputStream
14
+ OutputStream)))
11
15
12
16
(set! *warn-on-reflection* true )
13
17
72
76
(defn ^:private read-header-line
73
77
" Reads a line of input. Blocks if there are no messages on the input."
74
78
[^InputStream input]
75
- (let [s (java.lang.StringBuilder. )]
76
- (loop []
77
- (let [b (.read input)] ; ; blocks, presumably waiting for next message
78
- (case b
79
- -1 ::eof ; ; end of stream
80
- #_lf 10 (str s) ; ; finished reading line
81
- #_cr 13 (recur ) ; ; ignore carriage returns
82
- (do (.append s (char b)) ; ; byte == char because header is in US-ASCII
83
- (recur )))))))
79
+ (try
80
+ (let [s (java.lang.StringBuilder. )]
81
+ (loop []
82
+ (let [b (.read input)] ; ; blocks, presumably waiting for next message
83
+ (case b
84
+ -1 ::eof ; ; end of stream
85
+ #_lf 10 (str s) ; ; finished reading line
86
+ #_cr 13 (recur ) ; ; ignore carriage returns
87
+ (do (.append s (char b)) ; ; byte == char because header is in US-ASCII
88
+ (recur ))))))
89
+ (catch IOException _e
90
+ ::eof )))
84
91
85
92
(defn input-stream->input-chan
86
93
" Returns a channel which will yield parsed messages that have been read off
You can’t perform that action at this time.
0 commit comments