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 locked after calling EmailConverter.emlToEmail(InputStream) #354
I'm writing a batch with Spring Batch.
The reader will read all .eml files in a certain directory and for each element read i call EmailConverter.emlToEmail(InputStream) method.
The last file converted into Email using this method is locked by the process. I dont know if 'm doing something wrong or if it can be a bug.
After doing this. for every last element converted (every time i launch the batch) it will be locked until processor and writer are executing. After the end of the process the lock on the .eml file on the disk will be released.
A screenshot of Resource Monitor (Windows built-in) that show the lock on the file after the call to EmailConverter.emlToEmail(InputStream):
Sorry for my bad English, hope someone of you can help me understand if I'm doing something wrong or if I encountered a bug.
Thank you guys 😃
Actually, the library takes no responsibility for input streams going in as it doesn't know the context in which the InputStream is created and managed. So after you give Simple Java Mail an input stream, you have to close it yourself. Alternatively, give Simple Java Mail a File or the EML String directly, then Simple Java Mail will close any input streams created in the process.
Activity
bbottema commentedon Nov 17, 2021
Actually, the library takes no responsibility for input streams going in as it doesn't know the context in which the InputStream is created and managed. So after you give Simple Java Mail an input stream, you have to close it yourself. Alternatively, give Simple Java Mail a File or the EML String directly, then Simple Java Mail will close any input streams created in the process.
Does that help?
alelunardi98 commentedon Nov 18, 2021
Thank you @bbottema. I just close the InputStream i gave to Simple Java Mail and i solved the issue 😄