You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Matt Benson (JIRA)" <ji...@apache.org> on 2010/03/02 20:21:27 UTC

[jira] Resolved: (JXPATH-133) Cloning the node pointers and '==' node pointers comparison

     [ https://issues.apache.org/jira/browse/JXPATH-133?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson resolved JXPATH-133.
--------------------------------

    Resolution: Fixed

> Cloning the node pointers and '==' node pointers comparison
> -----------------------------------------------------------
>
>                 Key: JXPATH-133
>                 URL: https://issues.apache.org/jira/browse/JXPATH-133
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: JDK 1.5.0_12, JBoss 4.0.5
>            Reporter: Vladimir Orlov
>
> During the implementation of JCR nodes support in JXPath (extending NodePonter's, NodeIterator's, NodePointerFactory ) I faced with the following situation: I was running a xpath query against the context (JXPathContext instance) like:
> context.iteratePointers("/child::* | @ * ")
> After that I got an exception JXPathException: "Cannot compare pointers that do not belong to the same tree: '/home' and '/home' " thrown from NodePointer.compareNodePointers(...) method. After debugging this case I've found that for the node pointers extracted via the "/child::* | @ * " xpath expression NodePointer.compareTo(Object) was invoked (and consequently NodePointer.compareNodePointers(...) ). In fact all node pointers matching the "/child::* | @ * " xpath expression had the same node pointer (I checked it against my implementations of NodePointerFactory, NodeIterator's etc.). But as I found for these node pointers they were initialized with different clones of the same parent node pointer. And the result was that in NodePointer.compareTo(Object) method the following "==" comparison evaluated in false for the different clones of the same parent node pointer:
>         if (parent == pointer.parent) {
>             return parent == null ? 0 : parent.compareChildNodePointers(this, pointer);
>         }
> As the workaround for this case I overrode the clone method for my NodePointer descendants to return 'this'. I think there is some misbalance made between the  usage of clone () method of NodePointer's and "==" comparison of NodePointers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.