Axiom
  1. Axiom
  2. AXIOM-166

getChildrenWithQName.next throws ClassCastException, OMChildrenQNameIterator implements Iterator but does not satisfy published interface behavior

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      OS : Any
      Axiom Version 1.2.5
      Java Runtime version : 1.5

      Description

      Given the following xml fragment

      <ns1:BOSettings xmlns:ns1="http://a.b.c/pro">
      <ns1:ObjectType>X</ns1:ObjectType>
      </ns1:BOSettings>

      Iterator objectTypeIt = bosettings.getChildrenWithName(helper.createQNameForField("ObjectType"));

      invoking

      OMElement element = objectTypeIt.next();

      throws a ClassCastException

      the OMChildrenQNameIterator return the first child which in this case is of type OMText

      the issue can be fixed by first calling hasNext and then next, the hasNext method has a side effect which allows the next to proceed correctly.

      This behavior does not obey the published Iterator documentation, the following is expected Iterator behavior

      Iterator<Integer> it = Arrays.asList(new Integer[]

      { Integer.valueOf(1), Integer.valueOf(2),}

      );

      do
      {
      it.next();
      } while(it.hasNext());

      will work correctly and is the expected behavior.

      Whereas calling it.next on an Iterator instance of type OMChildrenQNameIterator will result in a ClassCastException

      1. _286.diff
        6 kB
        Bhaskar Maddala

        Activity

        Bhaskar Maddala created issue -
        Bhaskar Maddala made changes -
        Field Original Value New Value
        Attachment _286.diff [ 12371673 ]
        Rich Scheuerle made changes -
        Priority Major [ 3 ] Blocker [ 1 ]
        Assignee Rich Scheuerle [ scheu@us.ibm.com ]
        Rich Scheuerle made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Rich Scheuerle made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Andreas Veithen made changes -
        Project WS-Commons [ 12310250 ] Axiom [ 12311190 ]
        Key WSCOMMONS-286 AXIOM-166
        Component/s AXIOM [ 12310703 ]
        Andreas Veithen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Rich Scheuerle
            Reporter:
            Bhaskar Maddala
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development