Skip to content

Commit 4b6da5e

Browse files
committed
CLJS-2879: Close analysis cache file
Sets things up so that the file output stream is closed and that we also set up a buffered output stream and remove related unused imports.
1 parent cecb9af commit 4b6da5e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
[cljs.tools.reader :as reader]
3333
[cljs.tools.reader.reader-types :as readers]
3434
[cljs.reader :as edn]))
35-
#?(:clj (:import [java.io File Reader PushbackReader FileOutputStream FileInputStream]
35+
#?(:clj (:import [java.io File Reader PushbackReader]
3636
[java.util.regex Pattern]
3737
[java.net URL]
3838
[java.lang Throwable]
@@ -4520,10 +4520,8 @@
45204520
(str ";; Analyzed by ClojureScript " (util/clojurescript-version) "\n"
45214521
(pr-str analysis)))
45224522
"json" (when-let [{:keys [writer write]} @transit]
4523-
(write
4524-
(writer (FileOutputStream. cache-file) :json
4525-
transit-write-opts)
4526-
analysis))))
4523+
(with-open [os (io/output-stream cache-file)]
4524+
(write (writer os :json transit-write-opts) analysis)))))
45274525
(when src
45284526
(.setLastModified ^File cache-file (util/last-modified src))))))
45294527

0 commit comments

Comments
 (0)