You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by sfont <st...@gmail.com> on 2014/01/21 17:46:11 UTC

Temporary files created for data over 64kb are never deleted - swaref

Hi,
we are facing an issue with a cxf 2.7.4 client that runs on Apache Tomcat 6
and jdk 6 (both on windows and Linux). 

The problem is similar to that described in this already closed issue:

https://issues.apache.org/jira/browse/CXF-2106

When the response from the server contains an attachment whose size is
greater than 64KB a file in a folder like "/tmp/cxf-tmp-189150" is created
and never deleted.

The main difference with respect to that issue is that the attachments in
the message are not delivered according to the standard MTOM but the wsdl
uses the "swaref" standard. I include below a simplified extract from the
wsdl:



The generated java class "Document" contains a field with a DataHandler, as
expected, for the swaref element:



In the complex type there is also an mtom element that uses the mtom
standard but we have to use the swaref for a restriction on the server.

Any ideas?
Thank you very much.
Stefano




--
View this message in context: http://cxf.547215.n5.nabble.com/Temporary-files-created-for-data-over-64kb-are-never-deleted-swaref-tp5738911.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Temporary files created for data over 64kb are never deleted - swaref

Posted by Daniel Kulp <dk...@apache.org>.
On Jan 22, 2014, at 4:59 AM, sfont <st...@gmail.com> wrote:
> 
> One last question: if a soap response contains more elements that reference
> the same content id (the correct value not as as in our wrong response) is
> it anyhow necessary to open and close the stream on every DataHandler also
> if they references the same binary content -  file? Perhaps, may a custom
> interceptor (that forces the closure of all attachments ) attached to a
> opportune phase, help to mantain the code cleaner?

That definitely could would work.   At the VERY VERY end of the in chain, you could possibly grab the attachment list out of the message and just loop through and close each one.   

It’s not something we’d do by default as we don’t know what you are doing with the attachments.   People could be grabbing the attachment datahandlers and throwing them onto a background thread or something to be processed later.   If we consumed/deleted them, that could cause issue.   However, if you know you aren’t doing that, a simple interceptor could handle that for you.


-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Temporary files created for data over 64kb are never deleted - swaref

Posted by sfont <st...@gmail.com>.
Hi Daniel,
thank you for your quick reply!

Yes, we close and consume the "main document" stream however we have
activated the LoggingInInterceptor and we have found that the soap response
from the server is a little bit "dirty". More in detail:

-  the multipart contains two parts: the soap envelope and the binary
content of the document. 
- in the soap body we have found there are two different elements with a
swaref element inside (one is unexpected). The first one references the
correct "content id" of the document. The second one instead references a
content id that doesn't exists.

Anyhow if we force a call to the method "getInputstream" and "close" of that
stream immediatly on the DataHandler of the "dirty" element, the file is
deleted :)

One last question: if a soap response contains more elements that reference
the same content id (the correct value not as as in our wrong response) is
it anyhow necessary to open and close the stream on every DataHandler also
if they references the same binary content -  file? Perhaps, may a custom
interceptor (that forces the closure of all attachments ) attached to a
opportune phase, help to mantain the code cleaner?

Thank you very much.
Stefano




--
View this message in context: http://cxf.547215.n5.nabble.com/Temporary-files-created-for-data-over-64kb-are-never-deleted-swaref-tp5738911p5738951.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Temporary files created for data over 64kb are never deleted - swaref

Posted by Daniel Kulp <dk...@apache.org>.
In your code, are you calling dataHandler.getInputStream().close()?    Are you consuming the input stream as well?

That should cause the file to delete.  

Dan



On Jan 21, 2014, at 11:46 AM, sfont <st...@gmail.com> wrote:

> Hi,
> we are facing an issue with a cxf 2.7.4 client that runs on Apache Tomcat 6
> and jdk 6 (both on windows and Linux). 
> 
> The problem is similar to that described in this already closed issue:
> 
> https://issues.apache.org/jira/browse/CXF-2106
> 
> When the response from the server contains an attachment whose size is
> greater than 64KB a file in a folder like "/tmp/cxf-tmp-189150" is created
> and never deleted.
> 
> The main difference with respect to that issue is that the attachments in
> the message are not delivered according to the standard MTOM but the wsdl
> uses the "swaref" standard. I include below a simplified extract from the
> wsdl:
> 
> 
> 
> The generated java class "Document" contains a field with a DataHandler, as
> expected, for the swaref element:
> 
> 
> 
> In the complex type there is also an mtom element that uses the mtom
> standard but we have to use the swaref for a restriction on the server.
> 
> Any ideas?
> Thank you very much.
> Stefano
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Temporary-files-created-for-data-over-64kb-are-never-deleted-swaref-tp5738911.html
> Sent from the cxf-user mailing list archive at Nabble.com.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com