You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/08/02 00:13:01 UTC
svn commit: r799939 -
/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java
Author: veithen
Date: Sat Aug 1 22:13:00 2009
New Revision: 799939
URL: http://svn.apache.org/viewvc?rev=799939&view=rev
Log:
Make sure that DOOM's DocumentBuilder implementation closes parser and streams as necessary.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java?rev=799939&r1=799938&r2=799939&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java Sat Aug 1 22:13:00 2009
@@ -22,7 +22,6 @@
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.axiom.om.impl.dom.DOMImplementationImpl;
import org.apache.axiom.om.impl.dom.DocumentImpl;
-import org.apache.axiom.om.impl.dom.ElementImpl;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
import org.apache.axiom.om.util.StAXUtils;
import org.w3c.dom.DOMImplementation;
@@ -97,8 +96,8 @@
.createXMLStreamReader(inputSource.getCharacterStream());
StAXOMBuilder builder = new StAXOMBuilder(factory, reader);
DocumentImpl doc = (DocumentImpl) builder.getDocument();
- ((ElementImpl) doc.getDocumentElement()).build();
- return (DocumentImpl) builder.getDocument();
+ doc.close(true);
+ return doc;
} catch (XMLStreamException e) {
throw new SAXException(e);
}
@@ -111,7 +110,9 @@
XMLStreamReader reader = StAXUtils
.createXMLStreamReader(is);
StAXOMBuilder builder = new StAXOMBuilder(factory, reader);
- return (DocumentImpl) builder.getDocument();
+ DocumentImpl doc = (DocumentImpl) builder.getDocument();
+ doc.close(true);
+ return doc;
} catch (XMLStreamException e) {
throw new SAXException(e);
}
@@ -119,14 +120,11 @@
/** @see javax.xml.parsers.DocumentBuilder#parse(java.io.File) */
public Document parse(File file) throws SAXException, IOException {
+ FileInputStream in = new FileInputStream(file);
try {
- OMDOMFactory factory = new OMDOMFactory();
- XMLStreamReader reader = StAXUtils
- .createXMLStreamReader(new FileInputStream(file));
- StAXOMBuilder builder = new StAXOMBuilder(factory, reader);
- return (DocumentImpl) builder.getDocument();
- } catch (XMLStreamException e) {
- throw new SAXException(e);
+ return parse(in);
+ } finally {
+ in.close();
}
}