You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Michele Vivoda (JIRA)" <ji...@apache.org> on 2011/04/12 05:48:05 UTC

[jira] [Commented] (JXPATH-148) false and false returns true

    [ https://issues.apache.org/jira/browse/JXPATH-148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13018691#comment-13018691 ] 

Michele Vivoda commented on JXPATH-148:
---------------------------------------

For me the problem is in InfosetUtil#booleanValue that uses only pointer.isActual() to determine if a NodePointer is true/false.
I am not sure but probably the test done is a necessary condition but not sufficient, node must be actual and then probably its value must be converted to boolean.
My partially tested solution is to change InfosetUtil#booleanValue in the part
if (object instanceof NodePointer) {
   NodePointer pointer = (NodePointer) object;
   if (pointer instanceof VariablePointer) {
      return booleanValue(pointer.getNode());
   }
   pointer = pointer.getValuePointer();
   return pointer.isActual() **&& booleanValue(pointer.getNode())**;
}

adding  **&& booleanValue(pointer.getNode())**;

This solution looks like has no backward compatibility issue for other models (xml) at least in my tests and should solve test for this issue 148.


> false and false returns true
> ----------------------------
>
>                 Key: JXPATH-148
>                 URL: https://issues.apache.org/jira/browse/JXPATH-148
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: WindowsXP
>            Reporter: Johannes Stelzer
>            Priority: Blocker
>         Attachments: Issue148Test.java
>
>
> Map<String, Object> map = new HashMap<String, Object>();
> map.put("h", false);
> JXPathContext c = JXPathContext.newContext(map);
> System.out.println(c.getValue("h  and h "));
> Prints: true !!! it should print false!
> System.out.println(c.getValue("h = true() and h = true()")); although prints correctly: false

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira