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

XMLStreamWriter setDefaultNamespace(null) throws NullPointerException

    Details

    • Subcomponent:
    • Resolved In Build:
      b06
    • CPU:
      x86_64
    • OS:
      windows_7

      Backports

        Description

        A DESCRIPTION OF THE PROBLEM :
        According to the JavaDoc 11 it is allowed to use null as argument to XMLStreamWriter.setDefaultNamespace():
        "Parameters:
            uri - the uri to bind to the default namespace, may be null"

        Since Java 8 the implementation within the subsequently called method 'isDefaultNamespace()' changed from:

            if (uri == defaultNamespace) {
                return true;
            }

        to:

            if (uri.equals(defaultNamespace)) {
                return true;
            }

        In cases where 'uri' is null the call of 'equals()' leads to a NullPointerException.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        XMLOutputFactory outFactory = XMLOutputFactory.newFactory();
        outFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
        BufferedOutputStream bufferedStream = new BufferedOutputStream(outStream);
        XMLStreamWriter xsw = outFactory.createXMLStreamWriter(bufferedStream, "UTF-8");
        xsw.setDefaultNamespace(null);


        ACTUAL -
        Caused by: java.lang.NullPointerException
                at java.xml/com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.isDefaultNamespace(XMLStreamWriterImpl.java:1733)
                at java.xml/com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.setDefaultNamespace(XMLStreamWriterImpl.java:458)

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: