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

StAX: Set XMLReporter on XMLInputFactory has no effect

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :
      java version "10" 2018-03-20
      Java(TM) SE Runtime Environment 18.3 (build 10+46)
      Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 4.15.7-1-ARCH #1 SMP PREEMPT Wed Feb 28 19:01:57 UTC 2018 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      For the following code:
      ```
              XMLInputFactory inputFactory = XMLInputFactory.newInstance();
              inputFactory.setXMLReporter((message, errorType, relatedInformation, location) -> {
                  if (errorType.equals("EncodingDeclInvalid")) {
                      return;
                  }
                  ExpatModule.FormError(message, errorType, relatedInformation, location);
              });
      ```

      The lambda is never triggered, because in the `com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl` class, the `StaxErrorReporter` never received the property from property manager.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The `XMLReporter` should be used when there is an parse exception.
      ACTUAL -
      The XMLReporter has no effect.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
              XMLInputFactory inputFactory = XMLInputFactory.newInstance();
              inputFactory.setXMLReporter((message, errorType, relatedInformation, location) -> {
                  if (errorType.equals("EncodingDeclInvalid")) {
                      return;
                  }
                  ExpatModule.FormError(message, errorType, relatedInformation, location);
              });
              XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader("<a>"));
      ---------- END SOURCE ----------

      Attachments

        Activity

          People

            joehw Joe Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: