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

Infinite loop in OMElement possible

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.2.8
    • None
    • None
    • Windows XP, Java 1.5_09, Axiom 1.1.1.

    Description

      > I discovered today that under certain circumstances you can create an
      > OMElementImpl that will go into an infinte loop if you call
      > getFirstElement(); The specific example I found is if you create an
      > OMElement via the SAXOMBuilder and pass the SAXOMBuilder and
      > incomplete/malformed series of events (example code below). The
      > workaround is to check isComplete() before calling getFirstElement(),
      > but it seems like there should be some other way to avoid this condition.
      >

      package axiomtest;

      import org.apache.axiom.om.OMElement;
      import org.apache.axiom.om.impl.builder.SAXOMBuilder;
      import org.xml.sax.Attributes;

      public class InfinteLoopDemo {

      public static void main(String[] args) throws Exception{

      SAXOMBuilder builder = new SAXOMBuilder();

      //builder.startPrefixMapping("test", "http://test.com");
      builder.startDocument();
      builder.startElement("http://test.com", "test", "test:http://test.com", new Attributes(){

      public int getIndex(String uri, String localName)

      { // TODO Auto-generated method stub return 0; }

      public int getIndex(String qName) { // TODO Auto-generated method stub return 0; }

      public int getLength()

      { // TODO Auto-generated method stub return 0; }

      public String getLocalName(int index)

      { // TODO Auto-generated method stub return null; }

      public String getQName(int index) { // TODO Auto-generated method stub return null; }

      public String getType(int index)

      { // TODO Auto-generated method stub return null; }

      public String getType(String uri, String localName) { // TODO Auto-generated method stub return null; }

      public String getType(String qName)

      { // TODO Auto-generated method stub return null; }

      public String getURI(int index) { // TODO Auto-generated method stub return null; }

      public String getValue(int index)

      { // TODO Auto-generated method stub return null; }

      public String getValue(String uri, String localName) { // TODO Auto-generated method stub return null; }

      public String getValue(String qName)

      { // TODO Auto-generated method stub return null; }

      });
      OMElement root = builder.getRootElement();
      OMElement firstChild = root.getFirstElement();
      System.out.println("First child is: " + firstChild);

      }

      }

      Attachments

        1. InfinteLoopDemo.java
          3 kB
          Ryan Nelsestuen

        Activity

          People

            veithen Andreas Veithen
            ryannelsestuen Ryan Nelsestuen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: