Skip to content

Commit efbc43a

Browse files
committed
close stream when convert to array
1 parent 31abd68 commit efbc43a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/clj_http/util.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@
5757
(.toByteArray baos))))
5858

5959
(defn force-byte-array
60-
"force b as byte array if it is an InputStream."
60+
"force b as byte array if it is an InputStream, also close the stream"
6161
[b]
6262
(if (instance? java.io.InputStream b)
63-
(IOUtils/toByteArray ^java.io.InputStream b)
63+
(try (IOUtils/toByteArray ^java.io.InputStream b)
64+
(finally (.close ^java.io.InputStream b)))
6465
b))
6566

6667
(defn inflate

0 commit comments

Comments
 (0)