Uploaded image for project: 'ODE'
  1. ODE
  2. ODE-1019

Schema load exception is not handled for captureSchema

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3.6
    • 1.3.7, 1.4
    • Deployment
    • None

    Description

      There is the method for wsdl schema parsing(org.apache.ode.utils.xsd.XSUtils.captureSchema(LSInput, XMLEntityResolver)) where schema load exceptions and errors are handled incorrectly.
      First case when we receive model but there were errors during parsing:

      XSModel model = schemaLoader.load(input);
      if (model != null && errors.size() != 0) { // TODO: throw Exception}
      

      The question is do we need to throw Exception in this case.

      Second case when exceptions were thrown during parsing in xerces:

      org.apache.xerces.impl.xs.XMLSchemaLoader.load(LSInput)
          
          public XSModel load(LSInput is) {
              try {
                  Grammar g = loadGrammar(dom2xmlInputSource(is));
                  return ((XSGrammar) g).toXSModel();
              } catch (Exception e) {
                  reportDOMFatalError(e); // will be printed as System.err
      	    //reportDOMFatalError=>fErrorHandler.getErrorHandler().handleError(error);
                  return null;
              }
          }
      

      Fix for the second case can be handler creation which implements DOMErrorHandler and collects all exceptions in handleError(DOMError error) method.
      schemaLoader should be configured with this handler:

      LoggingDOMErrorHandler deh = new LoggingDOMErrorHandler(__log);
      schemaLoader.setParameter(Constants.DOM_ERROR_HANDLER, deh);
      

      And after load schema call we can check exceptions size like it is done for errors:

      ArrayList<Exception> exceptions = deh.getExceptions();
      XSModel model = schemaLoader.load(input);
      if (exceptions.size() != 0) { // TODO: throw Exception}
      

      Attached test to reproduce second case and exception handler class.

      Attachments

        1. LoggingDOMErrorHandler.java
          0.8 kB
          Igor Vorobiov
        2. SchemaCaptureTest.java
          1 kB
          Igor Vorobiov

        Issue Links

          Activity

            People

              vanto Tammo van Lessen
              ivorobiov Igor Vorobiov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: