Craig Ludington  committed a985f90

Use with-open to close the new FileInputStream in the digest method taking a File as an argument.

I don't know how to write a test for the file descriptor leak -- without looking at a /proc filesystem,
or parsing the output of lsof.

I've tested this at the REPL and it works (and fixes a nasty file descriptor leak in my own program).

  • Participants
  • Parent commits 5485be8
  • Branches default

Comments (0)

Files changed (1)

File src/digest.clj

   (digest algorithm [message]))
 (defmethod digest File [algorithm ^File file]
-  (digest algorithm (FileInputStream. file)))
+  (with-open [f (FileInputStream. file)]
+    (digest algorithm f)))
 (defmethod digest InputStream [algorithm ^InputStream reader]
   (digest algorithm (byte-seq reader)))