Just a followup to the previous post - since I've been unable to find a method that closes resources for a client RPC call that involves one or more attachments, and hoping that some doc I've seen about stream closing stuff (and other things) done at finalizer time is correct,, I used a profiler. It shows that the Call object, DataHandler object, the xxxSoapBindingStub object and a significant number of related objects are all retained after use. Nulling the root references to these is insufficient beacuase it looks like a ThreadLocal pattern is in use in the Axis code for stuff related to the Call object. After seeing this, I coded this convoluted sequence of steps to see if finalizer activity would allow me to delete the attachment file after it is sent:
1) Execute the DataHandler, xxxServiceLocator and xxxSoapBindingStub code used to do the web service call on a separate Thread, keep all references local to the Thread so at end of thread all should be garbage collectable 2) wait until thread completes, then null the reference to the Thread so it is garbage collectable as well, and more inportantly so the Axis-related ThreadLocal stuff is garbage collectible 3) Call System.gc() (yes, I know this is unreliable) 4) The Axis use of finalizers seems to then close everything up 5) Manipulate the attachment file successfully as now there are no open streams on it (assuming GC did its thing) I'm gonna start looking at CVS source for a better, more reliable way of handling this situation. If anyone already knows the answer, I'd love to hear it :-) If I find anything in the source, or come up with ideas for a patch, I'll post further on the dev list.
