You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by st...@illinoispower.com on 2004/09/24 01:18:47 UTC

ttachment and closed stream question

I'm using 1.2B3 of axis and calling a simple web service that passes a
DataHandler as an argument to send a file as an attachment.  Both the
server and client are using Axis 1.2B3.  The client uses the generated
stubs from wsdl2java.  Everything works, but after the client returns from
calling the binding stub, if I try to delete the file that was sent as an
attachment the delete fails because the file is still open somewhere in the
Axis code.  Here's some sample client code to illustrate (with some names
changed):

         String fileName = "<some local file>";
        DataHandler attachedFile = new DataHandler(new URL(<file url string
for above fileName>));
        FooServiceLocator locator =  new FooServiceLocator();
        FooSoapBindingStub binding = (FooSoapBindingStub)
locator.getFoos();
        binding.submitFile(fileName, attachedFile);

        // attached file still open here so can't manipulate
(delete/rename/etc) the file that was sent, next line doesn't help
        attachedFile.getInputStream().close();

I added the last line in an attempt to get the input stream from the
DataHandler closed to see if that would free up the open handle on the
file, but no help.  Couple questions in case anyone is familiar with this:
Is it the responsibility of the caller to close a DataHandler's resources
after use? If so, how do I explicitly close any open stream(s) properly?
If not, I've seen some references that indicate that Axis attachment
streams are closed at GC time - is that true and if so is there a way
around it so that the file can be manipulated or deleted immediately after
being sent?

Thanks in advance for any info.  Barring new info from anyone my next step
is to run this in a profiler and see who has the open stream(s) and work
backwards from there - it'd be great to avoid that work ;)