You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File MIME overload does not close its own input stream #670
The emlToMimeMessage(File, ...) overload creates a FileInputStream and delegates to emlToMimeMessage(InputStream, ...). The delegated path does not close the stream, which is correct for a caller-owned InputStream but leaks the stream created by the File overload. Repeated conversions can retain descriptors and file locks.
Code path
modules/simple-java-mail/src/main/java/org/simplejavamail/converter/EmailConverter.java:659-664: creates the FileInputStream.
EmailConverter.java:681-687: builds the MIME message from the stream without closing it.
Steps to reproduce
Repeatedly call the File overload on a temporary EML file and inspect open descriptors or attempt to delete the file before garbage collection. The checked source path contains no try-with-resources or explicit close for the stream created at line 661.
Expected behavior
The File overload should close the stream it creates on both success and failure. The InputStream overload should continue to preserve caller ownership.
Actual behavior
The File overload hands its stream to a non-closing InputStream path and returns without deterministic cleanup.
Existing coverage
Issue #354 discusses the ownership of caller-provided streams, and related delegation changes do not close this File overload. No exact fix was found.
Suggested fix
Wrap the internally-created FileInputStream in try-with-resources at the File overload boundary. Do not change the ownership behavior of the InputStream overload.
Suggested tests
File overload closes a tracking stream on success.
File overload closes it when MIME parsing fails.
Caller-provided InputStream remains open after conversion.
Repeated conversion does not leave the EML file locked.
Fixed on develop: emlToMimeMessage(File, ...) now closes the stream it creates after synchronous conversion, while caller-provided InputStream ownership remains unchanged. Targeted for 9.1.4.
Activity
fix(converter): close internally owned EML file streams (#669, #670)
bbottema commentedon Aug 5, 2026
Fixed on
develop:emlToMimeMessage(File, ...)now closes the stream it creates after synchronous conversion, while caller-providedInputStreamownership remains unchanged. Targeted for 9.1.4.bbottema commentedon Aug 5, 2026
Released in Simple Java Mail 9.1.4 and available from Maven Central.