You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Nico Max (JIRA)" <ji...@apache.org> on 2007/04/17 00:10:15 UTC

[jira] Created: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

boolean conversion of javabean getter values returning NULL fails
-----------------------------------------------------------------

                 Key: JXPATH-80
                 URL: https://issues.apache.org/jira/browse/JXPATH-80
             Project: Commons JXPath
          Issue Type: Bug
    Affects Versions: 1.2 Final
         Environment: java.runtime.name=Java(TM) SE Runtime Environment
java.runtime.version=1.6.0-b105
java.specification.name=Java Platform API Specification
java.specification.vendor=Sun Microsystems Inc.
java.vm.info=mixed mode
java.vm.name=Java HotSpot(TM) Client VM
            Reporter: Nico Max
            Priority: Minor


According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12490162 ] 

Nico Max commented on JXPATH-80:
--------------------------------

>From my above saying, that "java.lang.Object" is not a basic Xpath type, is slightly wrong, as the property value itself might be. 

Anyway, as for the testcase, the property value itself is NULL; thus cannot be treated as for something else as an empty node list.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: patch.patch, patch.patch, test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489449 ] 

Matt Benson commented on JXPATH-80:
-----------------------------------

Wow, this is a nice one.  I understand what's happening; I don't claim that my fundamental xpath knowledge is necessarily up to the task of deciding what to do about it.  I modified your testcase somewhat and find that you are correct.  JXPath has some substantially complex code, but the problem is linked to the fact that a collection encountered in the object graph is like an invisible node:  the collection name refers collectively to its members.  Thus, any property that might hold a collection (e.g. one of type Object) is viewed as an empty collection, so the null node one expects to be compared with false() isn't found.  Similarly, look at this example:

class Bean {
  public Object getValue5() {
    return new Object[] { "foo", "bar", null };
  }
}

Here, both of the following xpaths are true--

  "bean/value5 = true()"
  "bean/value5 = false()"

--because both null and non-null values are found in the property "value."  This seems somewhat nonsensical in the same way the original error does, but I'm not sure how deep the changes to address this would be, nor am I sure whether this is truly incorrect, or just strange.  I will have to do further research as I am able, and of course, input from any other quarter is welcome.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489895 ] 

Matt Benson commented on JXPATH-80:
-----------------------------------

Hmm, I had missed the isCollection() method.  The meat of your change--i.e. the part needed to make the testcase pass--is at the end of getLength():

-        return ValueUtils.getLength(getBaseValue());
+        return isCollection() ? ValueUtils.getLength(getBaseValue()) : 1;

Because isCollection() already returns false when the base value is null, I would feel okay about this change.  However, it breaks another testcase that tests whether the expression [1] returns a value relative to null.  The proposed change makes null have a size of 1, when the existing test expects no result due to null having a size of 0.  This still requires research into XPATH dogma.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: patch.patch, patch.patch, test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nico Max updated JXPATH-80:
---------------------------

    Attachment: patch.patch

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: patch.patch, test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nico Max updated JXPATH-80:
---------------------------

    Attachment: patch.patch

I've forgot to grant license; sorry

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: patch.patch, patch.patch, test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489886 ] 

Nico Max commented on JXPATH-80:
--------------------------------

I've tracked this down and I think I was able to resolve the issue.

First off, my testbean was not public as for one reason for the test to fail ... :-)

There is a method retrieving the length of a collection-like result of a bean getter in BeanPropertyPointer, but a real check for the NULL-case was missing, so I've patched that.

Unfortunately this does not fix your findings so I guess this issue should stay open.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Resolved: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Matt Benson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Benson resolved JXPATH-80.
-------------------------------

    Resolution: Invalid

Hi--sorry it took me so long to get back to this issue.  After much tail-chasing I have come to the conclusion that this issue is a red herring.  Your test attachment isn't performing "boolean conversions" but equality comparisons.  A boolean conversion is accomplished by calling the built-in boolean() function, and these seem to perform as expected.  equality comparisons do not automatically convert between types in the way you are expecting.  See http://www.w3.org/TR/xpath#booleans for more information about how these comparisons are specified.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: patch.patch, patch.patch, test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nico Max updated JXPATH-80:
---------------------------

    Description: 
According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.

It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

  was:According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.


> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12490148 ] 

Nico Max commented on JXPATH-80:
--------------------------------

The Javadoc of getLength() states, that it returns "1" if the property does not contain a collection, which is the case for a NULL-property value; so I thought to be safe.

Lets wrap up the XPath v1.0 spec. 

- (chap. 1):  "An expression is evaluated to yield an object, which has one of the following four basic types:

node-set (an unordered collection of nodes without duplicates) 
boolean (true or false) 
number (a floating-point number) 
string (a sequence of UCS characters)."

- (chap 3.4): " If one object to be compared is a node-set and the other is a boolean, then the comparison will be true if and only if the result of performing the comparison on the boolean and on the result of converting the node-set to a boolean using the boolean function is true."

- (chap. 4.3): The boolean() function treats nodesets like this:

             "a node-set is true if and only if it is non-empty"

So the location path in the expression "bean/value1 = false()" (from the attached test) is supposed to result in an empty node set, as "java.lang.Object" is not one of the other basic Xpath types. And an empty node set is being treated as "false" in an equality operation.

Yes, the test fails with the patch, but it fails without the patch too after applying the following additions:

- Give the TestNull-class a getter like this:

    public String getNothing2() {
    	return null;
    }

- Add the following assert to MixedModelTest.testNull():

        assertXPathValueIterator(
                context,
                "$testnull/nothing2",
                Collections.EMPTY_LIST);

This gives the same result.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: patch.patch, patch.patch, test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.
> It seems that the type the bean getter returns matters, as a NULL String for example works as expected.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (JXPATH-80) boolean conversion of javabean getter values returning NULL fails

Posted by "Nico Max (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JXPATH-80?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nico Max updated JXPATH-80:
---------------------------

    Attachment: test.java

The testcase.

> boolean conversion of javabean getter values returning NULL fails
> -----------------------------------------------------------------
>
>                 Key: JXPATH-80
>                 URL: https://issues.apache.org/jira/browse/JXPATH-80
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.2 Final
>         Environment: java.runtime.name=Java(TM) SE Runtime Environment
> java.runtime.version=1.6.0-b105
> java.specification.name=Java Platform API Specification
> java.specification.vendor=Sun Microsystems Inc.
> java.vm.info=mixed mode
> java.vm.name=Java HotSpot(TM) Client VM
>            Reporter: Nico Max
>            Priority: Minor
>         Attachments: test.java
>
>
> According to the JXPath User Guide a Javabean Getter returning NULL, regadless of the type, will be converted bo Boolean FALSE. But trying to build a boolean expression from this fails as the attached testcase shows.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org