[ 
https://issues.apache.org/jira/browse/MIME4J-72?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Markus Wiederkehr updated MIME4J-72:
------------------------------------

    Attachment: mime4j-dispose-finalize.patch

mime4j-dispose-finalize.patch is another patch for this issue I would like to 
be considered. I hope it can be included in 0.5.

The main changes are:
*) AbstractBody, Entity and Multipart have a boolean flag named 'disposed' to 
keep track if they have been disposed. Invoking dispose() a second time has no 
effect.
*) Once disposed all other methods throw a runtime exception (explicit check in 
setters, implicit NPEs in getters).
*) Most importantly AbstractBody, Entity and Multipart also have a finalizer 
that invokes dispose(). This is the same kind of safety net that is used by 
FileInputStream to invoke close(), for example.
*) SimpleTempStorage now actually tries to delete the backing file if delete() 
is invoked. If the deletion fails (e.g. because a stream is still open) the 
file is remembered for later deletion.
*) Additional unit tests

A side effect of this patch is that getParent() and setParent() are removed 
from TempFileBinaryBody because this is already handled by AbstractBody.

> Provide a means to dispose a Message
> ------------------------------------
>
>                 Key: MIME4J-72
>                 URL: https://issues.apache.org/jira/browse/MIME4J-72
>             Project: JAMES Mime4j
>          Issue Type: Improvement
>    Affects Versions: 0.5
>            Reporter: Markus Wiederkehr
>            Assignee: Robert Burrell Donkin
>         Attachments: mime4j-disposable.patch, mime4j-dispose-finalize.patch
>
>
> Currently an org.apache.james.mime4j.message.Message uses temporary files to 
> store text and binary attachments of the message. Unfortunately a Message 
> cannot be disposed of explicitly. Even when it eventually gets garbage 
> collected the temp files continue to exist until the VM exits.
> If the VM runs for a long time and a lot of e-mails get processed this can 
> become a major problem.
> For this reason I think that class Entity and interface Body should both have 
> a method to dispose of the object. Multipart should dispatch a dispose-call 
> to its list of body parts. A BodyPart should dispose of its body and concrete 
> Body implementation such as TempFileTextBody should ultimately invoke 
> delete() on the backing TempFile.
> Last but not least SimpleTempStorage$SimpleTempFile should not silently 
> ignore delete-calls.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to