Skip to content

Commit bb98e6a

Browse files
committed
Fix missing arity on async OutputStream
Regression caused by commit ae72f28 (PR #428). Proxy methods require all overloaded arities to be handled, so because the 3 arity form of .write was overloaded, the 1 arity form needed to be overloaded as well. Fixes #436.
1 parent b93e341 commit bb98e6a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

ring-servlet/src/ring/util/servlet.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@
8484
(if (nil? context)
8585
os
8686
(proxy [java.io.FilterOutputStream] [os]
87-
(write [b off len]
88-
(.write os b off len))
87+
(write
88+
([b] (.write os b))
89+
([b off len] (.write os b off len)))
8990
(close []
9091
(.close os)
9192
(.complete context))))))

ring-servlet/test/ring/util/test/servlet.clj

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns ring.util.test.servlet
22
(:require [clojure.test :refer :all]
3-
[ring.util.servlet :refer :all])
3+
[ring.util.servlet :refer :all]
4+
[ring.core.protocols :as proto])
45
(:import [java.util Locale]))
56

67
(defmacro ^:private with-locale [locale & body]
@@ -204,3 +205,16 @@
204205
(deftest defservice-test
205206
(defservice-test* foo-service)
206207
(defservice-test* -service))
208+
209+
(deftest make-output-stream-test
210+
(let [response (atom {})]
211+
(update-servlet-response
212+
(servlet-response response)
213+
(async-context (atom false))
214+
{:status 200
215+
:headers {}
216+
:body (reify proto/StreamableResponseBody
217+
(write-body-to-stream [_ _ os]
218+
(.write os (int \h))
219+
(.write os (.getBytes "ello"))))})
220+
(is (= "hello" (.toString (:body @response))))))

0 commit comments

Comments
 (0)