[SWS-783] SaxUtils leaks file handles, locks file on Windows Created: 27/Jun/12  Updated: 15/Apr/13  Resolved: 07/Aug/12

Status: Resolved
Project: Spring Web Services
Component/s: XML
Affects Version/s: 2.1 GA
Fix Version/s: 2.1.1

Type: Bug Priority: Minor
Reporter: Kristian Rosenvold Assignee: Arjen Poutsma
Resolution: Invalid Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 35m
Original Estimate: Not Specified

Attachments: Text File Added_closeable_support_to_saxutils.patch     Text File Added_closeable_support_to_saxutils1-v2.patch    

 Description   

The method "createInputSource" in SaxUtils leaks the input stream in

InputSource inputSource = new InputSource(resource.getInputStream());

While this might be considered a small nuisance, it becomes a PITA on Windows, because the "SimpleXsdSchema" uses this method and therefore locks the "xsd" file in the file system, which is a pain when running "mvn clean install" because clean fails because the XSD/WSDL file is locked.

There are basically 4 non-test usages of this method that need to be reworked to avoid leaking file handles.



 Comments   
Comment by Kristian Rosenvold [ 27/Jun/12 ]

The enclosed patch adds a "CloseableInputSource" that can be properly closed.

The test-cases on spring-ws seem to be quite far from working on windows, so I am unable to run them.

I am unsure of how this should be tested (if necessary).

Comment by Kristian Rosenvold [ 27/Jun/12 ]

It's locking on the WSDL too. Update coming soon

Comment by Kristian Rosenvold [ 27/Jun/12 ]

And here's version 2 that does not lock the wsdl file either

Comment by Arjen Poutsma [ 10/Jul/12 ]

Thanks for work you put into those patches, but I cannot confirm the problem actually exists. According to the InputSource Javadoc, the underlying input stream should be closed as part of the parsing process:

[...] standard processing of both byte and character streams is to close them on as part of end-of-parse cleanup, so applications should not attempt to re-use such streams after they have been handed to a parser.

I did some further testing on this by putting a breakpoint on InputStread.close(), and it does get called as part of DocumentBuilder.parse(). All of this on MacOS X, using the standard Oracle JDK (1.7.0_04-b21).

Are you using the standard Oracle JDK Xerces parser, or perhaps using something else, like the IBM JDK or a different parser?

Comment by Arjen Poutsma [ 07/Aug/12 ]

Closing as invalid for now.

Comment by roger pack [ 12/Apr/13 ]

also possibly related: http://betterlogic.com/roger/2013/04/documentbuilder-file-handle-leak-windows

Comment by Kristian Rosenvold [ 15/Apr/13 ]

@roger "not really", since I've been running on java7 all along.

Generated at Mon Dec 11 19:04:26 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.