Uploaded image for project: 'Axiom'
  1. Axiom
  2. AXIOM-432

Updating the last child is not correct unless we are replacing the last child

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.14
    • Component/s: DOOM
    • Labels:
      None

      Description

      I have a simple policy which encrypts a header. When the WSS for J decrypts I could see in the Dom model the decrypted header. Actually I have 3 headers of which one is encrypted in the Dom model. I see all the 3 headers after it is decrypted.
      But when it is converted into the OOM model some of the headers disappear.

      soapHeader.addHeaderBlock(element.getLocalName(), element.getNamespace()); statement

      I noticed that the lastChild field of the SOAPHeader block points to a header element somewhere in the middle of the list instead of the last one
      meaning if the Header block contains 3 headers HDR1 -> HDR2 -> HDR3
      then the lastChild should point to HDR3; instead it points to HDR2
      so when a new header HDR4 is added, instead of the list becoming HDR1 -> HDR2 -> HDR3 -> HDR4
      it becomes HDR1 -> HDR2 -> HDR4 skipping HDR3

      The defect is in org.apache.axiom.om.impl.dom.ParentNode.replaceChild(Node, Node) ,line 414, where
      updating the last child is not correct unless we are replacing the last child.

      1. axiom432-test.zip
        10 kB
        Detelin Hadzhiev

        Activity

        Hide
        veithen Andreas Veithen added a comment -

        Do you have a test case to reproduce the issue?

        Can you specify the Axiom version with which the issue occurs (and to which the line number in ParentNode applies)?

        Show
        veithen Andreas Veithen added a comment - Do you have a test case to reproduce the issue? Can you specify the Axiom version with which the issue occurs (and to which the line number in ParentNode applies)?
        Hide
        d_hadzhiev Detelin Hadzhiev added a comment -

        I attached the test case in the issue.
        You will need axis2, and rampart to execute the example. Notice that after decrypting the custom "hdr1:HeaderLocal_1" header, "wsa:Action" header goes missing and Rampart's validation fails.
        There are client and service. This defect was found in version 1.2.7. Since the ParentNode is not changed a lot it should appear in the latest release as well.
        It apples at line 414 this.lastChild = (ChildNode)docFrag.getLastChild()

        Show
        d_hadzhiev Detelin Hadzhiev added a comment - I attached the test case in the issue. You will need axis2, and rampart to execute the example. Notice that after decrypting the custom "hdr1:HeaderLocal_1" header, "wsa:Action" header goes missing and Rampart's validation fails. There are client and service. This defect was found in version 1.2.7. Since the ParentNode is not changed a lot it should appear in the latest release as well. It apples at line 414 this.lastChild = (ChildNode)docFrag.getLastChild()
        Hide
        veithen Andreas Veithen added a comment -

        Are you sure about the Axiom version? I see a different instruction at line 414 in the ParentNode code from version 1.2.7 [1].

        [1] https://svn.apache.org/repos/asf/webservices/commons/tags/axiom/1.2.7/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java

        Show
        veithen Andreas Veithen added a comment - Are you sure about the Axiom version? I see a different instruction at line 414 in the ParentNode code from version 1.2.7 [1] . [1] https://svn.apache.org/repos/asf/webservices/commons/tags/axiom/1.2.7/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        Hide
        hudson Hudson added a comment -

        Integrated in ws-axiom-trunk #1106 (See https://builds.apache.org/job/ws-axiom-trunk/1106/)
        Fixed an issue in ParentNode#replaceChild that looks like AXIOM-432. (Revision 1362171)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildIncomplete.java
        Show
        hudson Hudson added a comment - Integrated in ws-axiom-trunk #1106 (See https://builds.apache.org/job/ws-axiom-trunk/1106/ ) Fixed an issue in ParentNode#replaceChild that looks like AXIOM-432 . (Revision 1362171) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildIncomplete.java
        Hide
        d_hadzhiev Detelin Hadzhiev added a comment -

        I meant line 414 in 1.2.13. Is the defect resolved now or not?

        Show
        d_hadzhiev Detelin Hadzhiev added a comment - I meant line 414 in 1.2.13. Is the defect resolved now or not?
        Hide
        veithen Andreas Veithen added a comment -

        Line 414 is in a code path that is executed only if the new child is a DocumentFragment. Are you sure that WSS4J is manipulating a DocumentFragment here?

        I fixed one issue in replaceChild, but this is in a different code path.

        Show
        veithen Andreas Veithen added a comment - Line 414 is in a code path that is executed only if the new child is a DocumentFragment. Are you sure that WSS4J is manipulating a DocumentFragment here? I fixed one issue in replaceChild, but this is in a different code path.
        Hide
        d_hadzhiev Detelin Hadzhiev added a comment -

        Yes I'm sure for axiom-1.2.7 and it should be reproducible with test example attached here.

        Show
        d_hadzhiev Detelin Hadzhiev added a comment - Yes I'm sure for axiom-1.2.7 and it should be reproducible with test example attached here.
        Hide
        hudson Hudson added a comment -

        Integrated in ws-axiom-trunk #1109 (See https://builds.apache.org/job/ws-axiom-trunk/1109/)
        AXIOM-432: Increased test coverage of ParentNode#replaceChild. (Revision 1362402)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirst.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildNotFound.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildNullNewChild.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildSingle.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildWithAncestor.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        Show
        hudson Hudson added a comment - Integrated in ws-axiom-trunk #1109 (See https://builds.apache.org/job/ws-axiom-trunk/1109/ ) AXIOM-432 : Increased test coverage of ParentNode#replaceChild. (Revision 1362402) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirst.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildNotFound.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildNullNewChild.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildSingle.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildWithAncestor.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        Hide
        hudson Hudson added a comment -

        Integrated in ws-axiom-trunk #1110 (See https://builds.apache.org/job/ws-axiom-trunk/1110/)
        AXIOM-432: Further increased the test coverage of ParentNode#replaceChild and fixed a couple of issues that occur when newChild is a document fragment. (Revision 1362582)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestInsertBeforeWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildCyclic.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirst.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirstWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLast.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLastWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddle.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddleWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildWithAncestor.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        Show
        hudson Hudson added a comment - Integrated in ws-axiom-trunk #1110 (See https://builds.apache.org/job/ws-axiom-trunk/1110/ ) AXIOM-432 : Further increased the test coverage of ParentNode#replaceChild and fixed a couple of issues that occur when newChild is a document fragment. (Revision 1362582) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestInsertBeforeWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChild.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildCyclic.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirst.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirstWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLast.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLastWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddle.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddleWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildWithAncestor.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        Hide
        veithen Andreas Veithen added a comment -

        Can you provide some instructions about how to run the sample?

        Show
        veithen Andreas Veithen added a comment - Can you provide some instructions about how to run the sample?
        Hide
        hudson Hudson added a comment -

        Integrated in ws-axiom-trunk #1214 (See https://builds.apache.org/job/ws-axiom-trunk/1214/)
        AXIOM-432: Added more test cases and assertions for Node#replaceChild and fixed several issues. (Revision 1384874)

        Result = SUCCESS
        veithen :
        Files :

        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/ReplaceChildTestCase.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirst.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirstWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLast.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLastWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddle.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddleWithDocumentFragment.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildSingle.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildFirstIncomplete.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildIncomplete.java
        • /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildMiddleIncomplete.java
        Show
        hudson Hudson added a comment - Integrated in ws-axiom-trunk #1214 (See https://builds.apache.org/job/ws-axiom-trunk/1214/ ) AXIOM-432 : Added more test cases and assertions for Node#replaceChild and fixed several issues. (Revision 1384874) Result = SUCCESS veithen : Files : /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/ReplaceChildTestCase.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirst.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildFirstWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLast.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildLastWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddle.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildMiddleWithDocumentFragment.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom-testsuite/src/main/java/org/apache/axiom/ts/dom/element/TestReplaceChildSingle.java /webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildFirstIncomplete.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildIncomplete.java /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/element/TestReplaceChildMiddleIncomplete.java
        Hide
        veithen Andreas Veithen added a comment -

        The reporter didn't provide the necessary instructions to execute the sample that is expected to show the issue. Nevertheless I believe that the issue is fixed: multiple problems in the implementation of the replaceChild method were found and have been corrected.

        Show
        veithen Andreas Veithen added a comment - The reporter didn't provide the necessary instructions to execute the sample that is expected to show the issue. Nevertheless I believe that the issue is fixed: multiple problems in the implementation of the replaceChild method were found and have been corrected.

          People

          • Assignee:
            veithen Andreas Veithen
            Reporter:
            d_hadzhiev Detelin Hadzhiev
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development