Skip to content

File locked after calling EmailConverter.emlToEmail(InputStream) #354

Closed

Description

@alelunardi98

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.

org.springframework.core.io.Resource = .....
Email email = EmailConverter.emlToEmail(resource.getInputStream());

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):

Immagine 2021-11-17 174807

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 😃

Activity

  1. bbottema commented on Nov 17, 2021

    @bbottema
    Owner

    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?

  2. alelunardi98 commented on Nov 18, 2021

    @alelunardi98
    Author

    Thank you @bbottema. I just close the InputStream i gave to Simple Java Mail and i solved the issue 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions