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

The setXIncludeAware method in SAXParserFactory throws obscure error message

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: 1.4.0
    • Component/s: xml
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.4
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        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/

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: