Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6481337

SAX2DOM creates JAXP SAXParserFactory unnecessarily

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 5.0
    • 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.

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

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: