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

The setXIncludeAware method in SAXParserFactory throws obscure error message

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 7
    • xml
    • 1.4
    • generic
    • generic
    • Verified

        JAXP SAXParserFactory has the setXIncludeAware method that reads like this:

        > > public void setXIncludeAware(final boolean state) {
        > > throw new UnsupportedOperationException(
        > > "This parser does not support specification \""
        > > + this.getClass().getPackage().getSpecificationTitle()
        > > + "\" version \""
        > > + this.getClass().getPackage().getSpecificationVersion()
        > > + "\""
        > > );
        > > }

        This most typically just results in the following error, which is not
        useful at all:

        > > Caused by: java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null"
        > > at javax.xml.parsers.SAXParserFactory.setXIncludeAware(SAXParserFactory.java:448)
        > > at org.jclouds.http.functions.config.ParserModule.provideSAXParserFactory(ParserModule.java:124)
        > > ... 146 more
        > >

        I find this getPackage()... business pointless. It's much better if the
        code is just

           throw new UnsupportedOperationException("setXIncludeAware is not
        supported on this JAXP 1.4 implementation or earlier: "+this.getClass());

        An extra bonus point is to let the method work silently if the state is
        false, since it's a no-op.

        -- Kohsuke Kawaguchi http://weblogs.java.net/blog/kohsuke/

              joehw Joe Wang
              joehw Joe Wang
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: