Last active
August 29, 2015 14:01
-
-
Save guns/bc722e7ffd9ad1ee92ee to your computer and use it in GitHub Desktop.
Closing resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example | |
(:require [clojure.java.io :as io]) | |
(:import (java.io FileInputStream) | |
(javax.mail Session) | |
(javax.mail.internet MimeMessage))) | |
;; Good | |
(defn ^MimeMessage message | |
[file] | |
(with-open [fis (FileInputStream. (io/file file))] | |
(MimeMessage. (Session/getDefaultInstance (System/getProperties)) fis))) | |
;; Bad | |
(defn ^MimeMessage message | |
[file] | |
(MimeMessage. (Session/getDefaultInstance (System/getProperties)) | |
(FileInputStream. (io/file file)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment