From a5318ea289a66acbb2b2fecdcf240ccc2dc184c7 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 21 Jan 2023 14:06:33 +0100 Subject: [PATCH] Allow java.io.OutputStream to be proxied, for kaocha --- src/babashka/impl/proxy.clj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/babashka/impl/proxy.clj b/src/babashka/impl/proxy.clj index f40b7ab1..30019c14 100644 --- a/src/babashka/impl/proxy.clj +++ b/src/babashka/impl/proxy.clj @@ -100,6 +100,18 @@ (write ([b] ((method-or-bust methods 'write) this b)) ([b off len] ((method-or-bust methods 'write) this b off len)))) + + ["java.io.OutputStream" #{}] + (proxy [java.io.PipedOutputStream] [] + (close [] (if-let [m (get methods 'close)] + (m this) + (proxy-super close))) + (flush [] (if-let [m (get methods 'flush)] + (m this) + (proxy-super flush))) + (write + ([b] ((method-or-bust methods 'write) this b)) + ([b off len] ((method-or-bust methods 'write) this b off len)))) , ;; keep this for merge friendliness )))