SAX2DOM creates JAXP SAXParserFactory unnecessarily

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 1.4.0
    • Affects Version/s: 5.0
    • Component/s: xml
    • 1.4
    • generic
    • generic
    • Verified

        com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM has the following code:

        -----------------
            public SAX2DOM() throws ParserConfigurationException {
        final DocumentBuilderFactory factory =
        DocumentBuilderFactory.newInstance();
        _document = factory.newDocumentBuilder().newDocument();
        _root = _document;
            }

            public SAX2DOM(Node root) throws ParserConfigurationException {
        _root = root;
        if (root instanceof Document) {
        _document = (Document)root;
        }
        else if (root != null) {
        _document = root.getOwnerDocument();
        }
        else {
        final DocumentBuilderFactory factory =
        DocumentBuilderFactory.newInstance();
        _document = factory.newDocumentBuilder().newDocument();
        _root = _document;
        }
            }
        -----------------

        This is showing up as a hot spot in JAX-WS because a new DocumentBuilderFactory is created every time. The factory should be created only once and set to a static final field, then reused.

              Assignee:
              Santiago Pericasgeertsen
              Reporter:
              Kohsuke Kawaguchi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: