XFire

JDOMReader.getNextAttributeReader() throws exception in some instances when hasMoreAttributeReaders() returns true

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2.1
  • Fix Version/s: 1.2.2
  • Component/s: Aegis Module
  • Labels:
    None
  • Number of attachments :
    0

Description

JDOMReader has a problem with its getNextAttributeReader() method. Take the following example code:

Element root = new Element("root");
root.setAttribute("id", "foo");

JDOMReader reader = new JDOMReader(root);
if (reader.hasMoreAttributeReaders())
{
    // This throws an IndexOutOfBoundsException
    MessageReader nextReader = reader.getNextAttributeReader();
}

The second line of getNextAttributeReader() is throwing an IndexOutOfBoundsException:

public MessageReader getNextAttributeReader()
{
    currentAttribute++;
    Attribute att = (Attribute) element.getAttributes().get(currentAttribute);
    
    return new AttributeReader(new QName(att.getNamespaceURI(), att.getName()), att.getValue());
}

The attribute that should be retrieved is currentAttribute - 1 since currentAttribute is incremented first.
This is causing an IndexOutOfBoundsException to be thrown on the last (or in this case the only) attribute.

Activity

Hide
Dan Diephouse added a comment -

Good catch. Thanks, we'll fix this shortly.

Show
Dan Diephouse added a comment - Good catch. Thanks, we'll fix this shortly.
Hide
Dan Diephouse added a comment -
Show
Dan Diephouse added a comment - Thanks for reporting. I've fixed this in SVN. You can grab a new build here: http://snapshots.repository.codehaus.org/org/codehaus/xfire/xfire-all/1.2-SNAPSHOT/xfire-all-1.2-20060915.183151-20.jar

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: