Axiom
  1. Axiom
  2. AXIOM-419

Multiple issues in OMDataSourceExtBase

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.13
    • Fix Version/s: 1.2.14
    • Component/s: API
    • Labels:
      None

      Description

      OMDataSourceExtBase has multiple issues and we should probably deprecate it in favor of a cleaner implementation:

      (1) The default implementation of serialize(OutputStream, OMOutputFormat) relies on getXMLBytes:

      output.write(getXMLBytes(format.getCharSetEncoding()));

      This is probably the worst choice from a performance point of view.

      (2) The default implementation of serialize(Writer, OMOutputFormat) is even worse:

      String text = new String(getXMLBytes(format.getCharSetEncoding()));
      writer.write(text);

      (3) serialize(XMLStreamWriter) tries to optimize the serialization by using serialize(OutputStream, OMOutputFormat) if the XMLStreamWriter is a MTOMXMLStreamWriter, i.e. it attempts to bypass the XMLStreamWriter. However, as noted in the Axiom 1.3 roadmap, this kind of optimization is non trivial and the serialize(OutputStream, OMOutputFormat) is not well designed for this. The issues that may arise can be demonstrated using the InputStreamDataSource (which extends OMDataSourceExtBase):

      OMFactory factory = OMAbstractFactory.getOMFactory();
      OMElement parent = factory.createOMElement("root", factory.createOMNamespace("urn:parent", ""));
      OMSourcedElement child = factory.createOMElement(new InputStreamDataSource(new ByteArrayInputStream("<child/>".getBytes("utf-8")), "utf-8"), new QName("child"));
      // child.getFirstOMChild();
      parent.addChild(child);
      parent.serializeAndConsume(System.out, new OMOutputFormat());

      The output of this code is:

      <root xmlns="urn:parent"><child/></root>

      This is incorrect because the namespace of the child element in the output is urn:parent while the original element has no namespace. If the line forcing the expansion of the OMSourcedElement is uncommented, then the result is correct:

      <root xmlns="urn:parent"><child xmlns=""/></root>

      (4) The class contains code (see the private reader2writer method) that copies events from the XMLStreamReader produced by getReader() to an XMLStreamWriter. However, that code actually fully builds an Axiom tree, which is the least optimal approach.

        Activity

        Andreas Veithen created issue -
        Andreas Veithen made changes -
        Field Original Value New Value
        Assignee Andreas Veithen [ veithen ]
        Fix Version/s 1.2.14 [ 12318340 ]
        Andreas Veithen made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #923 (See https://builds.apache.org/job/ws-axiom-trunk/923/)
        AXIOM-419: Added a new base class for OMDataSource(Ext) implementations that is clean and avoids the issues found in OMDataSourceExtBase. (Revision 1332356)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractPullOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceFromDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceFromReader.java
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #923 (See https://builds.apache.org/job/ws-axiom-trunk/923/ ) AXIOM-419 : Added a new base class for OMDataSource(Ext) implementations that is clean and avoids the issues found in OMDataSourceExtBase. (Revision 1332356) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractPullOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceFromDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/WrappedTextNodeOMDataSourceFromReader.java
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #949 (See https://builds.apache.org/job/ws-axiom-trunk/949/)

        • AXIOM-420: Added support for push-only OMDataSources.
        • The change also provides a regression test for AXIOM-421 because AbstractXMLStreamWriter is involved in both cases.
        • AXIOM-419: Added an AbstractPushOMDataSource as counterpart for AbstractPullOMDataSource. (Revision 1336376)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractPullOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractPushOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/PushOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetXMLStreamReaderWithPushOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestGetNamespaceContext.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteAttributeNoNamespace.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteDataHandler.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteDataHandlerProvider.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteEmptyElementAutoPrefix.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteNamespace.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementAutoPrefix.java
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #949 (See https://builds.apache.org/job/ws-axiom-trunk/949/ ) AXIOM-420 : Added support for push-only OMDataSources. The change also provides a regression test for AXIOM-421 because AbstractXMLStreamWriter is involved in both cases. AXIOM-419 : Added an AbstractPushOMDataSource as counterpart for AbstractPullOMDataSource. (Revision 1336376) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractPullOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractPushOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java /webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/PushOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/TestGetXMLStreamReaderWithPushOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestGetNamespaceContext.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteAttributeNoNamespace.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteDataHandler.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteDataHandlerProvider.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteEmptyElementAutoPrefix.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteNamespace.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/sourcedelement/push/TestWriteStartElementAutoPrefix.java
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #982 (See https://builds.apache.org/job/ws-axiom-trunk/982/)
        AXIOM-419: Clarify the contract of OMDataSourceExt#copy() and fixed the default implementation in AbstractOMDataSource accordingly. (Revision 1340679)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSourceExt.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractOMDataSource.java
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #982 (See https://builds.apache.org/job/ws-axiom-trunk/982/ ) AXIOM-419 : Clarify the contract of OMDataSourceExt#copy() and fixed the default implementation in AbstractOMDataSource accordingly. (Revision 1340679) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMDataSourceExt.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractOMDataSource.java
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #1165 (See https://builds.apache.org/job/ws-axiom-trunk/1165/)
        AXIOM-419: Updated user guide to take into account the introduction of AbstractPullOMDataSource. (Revision 1373934)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/src/docbkx/userguide.xml
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #1165 (See https://builds.apache.org/job/ws-axiom-trunk/1165/ ) AXIOM-419 : Updated user guide to take into account the introduction of AbstractPullOMDataSource. (Revision 1373934) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/src/docbkx/userguide.xml
        Hide
        Hudson added a comment -

        Integrated in ws-axiom-trunk #1168 (See https://builds.apache.org/job/ws-axiom-trunk/1168/)
        AXIOM-419: Deprecated OMDataSourceExtBase and added Javadoc to AbstractOMDataSource. (Revision 1374516)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractOMDataSource.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/OMDataSourceExtBase.java
        Show
        Hudson added a comment - Integrated in ws-axiom-trunk #1168 (See https://builds.apache.org/job/ws-axiom-trunk/1168/ ) AXIOM-419 : Deprecated OMDataSourceExtBase and added Javadoc to AbstractOMDataSource. (Revision 1374516) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/AbstractOMDataSource.java /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/ds/OMDataSourceExtBase.java
        Andreas Veithen made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        9h 3m 1 Andreas Veithen 30/Apr/12 20:41
        In Progress In Progress Resolved Resolved
        109d 13h 45m 1 Andreas Veithen 18/Aug/12 10:26

          People

          • Assignee:
            Andreas Veithen
            Reporter:
            Andreas Veithen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development