Hi Jonathan,
Kumar Jayanti wrote:
> Hi Jitu,
>
> Jonathan Avraham wrote:
>> Hi,
>>
>> I am using SAAJ 1.3.4 with mimepull enabled for large attachment support.
>> I am using getRawContent() from the attachment , I then proceed to
>> extract what I need from the Inputstream.
>> The problem is that the temp file created for the message is not
>> deleted and still kept open by the system, this means I can't even
>> delete it manually until I restart tomcat.
>> I have tried closing the Inputstream, clearing the content from the
>> attachment and clearing the hole SOAPMessage, nothing worked.
>>
>> What am i doing wrong?
>>
> I have obviously missed some step to clean up the temp files created
> by MimePull in my usage of the API in SAAJ. Can you tell me how we
> can cause the MimePull runtime to delete temp-files ?.
The SAAJ MessageImpl class holds onto the MimePullMultipart which
inturn holds the individual Mime Parts. So what did you mean by clearing
the whole SOAPMessage. Make sure you are setting all reference's to the
message in your application to null.
//application code
SOAPMessage message = ....
//code that uses the messages, reads attachments etc
//release the reference to the message
message = null;
If this still does not cleanup the temp files (after sometime) then i
believe i will need to talk to the MimePull lead and get back.From
looking at the code of MimePull, it appears they make use of
WeakReference to a DataFile. Try to force a GC cycle and see if that
clears it up. Are you running on Windows OS ?.
I would need feedback from you on whether any of this helps so i can
update the blog post. I will also try to experiment the condition that
you are seeing but i will get to it next week.
As far as i can see if you call clearContent() on an AttachmentPart the
code clears the MimePart that it is holding onto so this is definitely
not a problem.
regards,
kumar