Skip to content

Commit 9a1c51b

Browse files
Rasmus Svenssonstuarthalloway
authored andcommitted
Fix and tests for issue #404
Signed-off-by: Stuart Halloway <[email protected]>
1 parent 8aaca54 commit 9a1c51b

File tree

2 files changed

+15
-4
lines changed
  • src/clj/clojure/java
  • test/clojure/test_clojure/java

2 files changed

+15
-4
lines changed

src/clj/clojure/java/io.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
IOFactory
261261
(assoc default-streams-impl
262262
:make-input-stream (fn [^Socket x opts] (.getInputStream x))
263-
:output-stream (fn [^Socket x opts] (output-stream (.getOutputStream x) opts))))
263+
:make-output-stream (fn [^Socket x opts] (.getOutputStream x))))
264264

265265
(extend byte-array-type
266266
IOFactory

test/clojure/test_clojure/java/io.clj

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
(ns clojure.test-clojure.java.io
1010
(:use clojure.test clojure.java.io)
11-
(:import (java.io File FileInputStream BufferedInputStream
12-
FileOutputStream OutputStreamWriter InputStreamReader
11+
(:import (java.io File BufferedInputStream
12+
FileInputStream InputStreamReader InputStream
13+
FileOutputStream OutputStreamWriter OutputStream
1314
ByteArrayInputStream ByteArrayOutputStream)
14-
(java.net URL URI)))
15+
(java.net URL URI Socket ServerSocket)))
1516

1617
(defn temp-file
1718
[prefix suffix]
@@ -193,3 +194,13 @@
193194
(is (not (.isDirectory (file tmp "test-make-parents" "child" "grandchild"))))
194195
(delete-file (file tmp "test-make-parents" "child"))
195196
(delete-file (file tmp "test-make-parents"))))
197+
198+
(deftest test-socket-iofactory
199+
(let [port 65321
200+
server-socket (ServerSocket. port)
201+
client-socket (Socket. "localhost" port)]
202+
(try
203+
(is (instance? InputStream (input-stream client-socket)))
204+
(is (instance? OutputStream (output-stream client-socket)))
205+
(finally (.close server-socket)
206+
(.close client-socket)))))

0 commit comments

Comments
 (0)