Skip to content

Commit 7f29513

Browse files
committed
CLJS-1416: cljs.util/last-modified leaks files
1 parent 01830cf commit 7f29513

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/clojure/cljs/util.cljc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,14 @@
142142
(defn last-modified [src]
143143
(cond
144144
(file? src) (.lastModified ^File src)
145-
(url? src) (.getLastModified (.openConnection ^URL src))
145+
(url? src)
146+
(let [conn (.openConnection ^URL src)]
147+
(try
148+
(.getLastModified conn)
149+
(finally
150+
(let [ins (.getInputStream conn)]
151+
(when ins
152+
(.close ins))))))
146153
:else
147154
(throw
148155
(IllegalArgumentException. (str "Cannot get last modified for " src)))))

0 commit comments

Comments
 (0)