You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by ji...@apache.org on 2004/05/20 21:17:06 UTC

[jira] Commented: (XERCESJ-892) NodeList.item(-1) does not return null

The following comment has been added to this issue:

     Author: Jonathan Au
    Created: Thu, 20 May 2004 12:16 PM
       Body:
Patch has been verified. 
---------------------------------------------------------------------
View this comment:
  http://issues.apache.org/jira/browse/XERCESJ-892?page=comments#action_35648

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESJ-892

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESJ-892
    Summary: NodeList.item(-1) does not return null
       Type: Bug

     Status: Resolved
 Resolution: FIXED

    Project: Xerces2-J
 Components: 
             DOM
   Versions:
             2.6.0

   Assignee: Michael Glavassevich
   Reporter: Christian Roth

    Created: Wed, 18 Feb 2004 12:45 AM
    Updated: Thu, 20 May 2004 12:16 PM
Environment: Operating System: All
Platform: All

Description:
Calling nl.item(-1) on a NodeList nl does not return null (as required by the spec for an invalid 
index) sometimes.

>From the source, it looks like the code will indeed not return null for a NodeList of length >= 1, 
when the "long way" in ParentNode.java, #789, is used:

        else {
            // long way
            n = firstChild;
            for (i = 0; i < index && n != null; i++) {
                n = n.nextSibling;
            }
        }

n is initialized with firstChild, which probably is not null for a NodeList of size >= 1. Though the 
following loop never runs, n keeps the value of firstChild until method exit for the return value, 
even though the passed index is -1. This way, the first child node is returned instead of the 
expected value, null.

(Please note that the above is only a quick-glance-observation and I might be wrong on the real 
cause for NodeList.item(-1) (or any negative value, for that matter), not returning null in all cases as 
expected.)

Kind regards, Christian.


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org