[
https://issues.apache.org/jira/browse/JXPATH-151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18141961#comment-18141961
]
Markus Schlegel commented on JXPATH-151:
----------------------------------------
This issue is marked to be resolved, but there is no "Fix Versions" set. In
fact, the fix has been delivered with JXPath 1.4.0.
The fix causes severe impact in our Usage of JXPath since {*}it changes a
fundamental principle how null handling worked before this change{*}. Let me
explain why:
In JXPath 1.3.0, the XPath Expression "relation/secondRelation/someIntProperty"
applied to our Java Object Model revealed the Result of the Property named
"someIntProperty" in all related Objects which actually have a Property
someIntProperty set. If we have say 10 Objects related by the secondRelation
Relation, but only two of them have a value in the Property someIntProperty,
then the result was for example [4, 8].
With JXPath 1.4.0, the result is [null, null, null, null, null, null, null,
null, 4, 8].
Also, in 1.3, when we had an expression which read through some relations of
our Objectmodel like "relation/secondRelation" but could not find any related
object for the second relation, but say 4 objects on the first, then the result
was an empty Collection (since it indeed did not find any object that applies
to the expression).
With 1.4, it returns a Collection of 4 "null" values, since it found 4 Objects
for the first relation but no hit for the second.
First of all, this is an incompatible change which will break many usages of
JXPath. Unfortunately, it is not part of the release notes and there is no hint
about this.
Second, I don't think, that the fix for the described problem should have had
this impact.
> null handling is inconsistent
> -----------------------------
>
> Key: JXPATH-151
> URL: https://issues.apache.org/jira/browse/JXPATH-151
> Project: Commons JXPath
> Issue Type: Bug
> Affects Versions: 1.3
> Environment: windows oracle jvm 1.6_25
> Reporter: Johannes Stelzer
> Priority: Blocker
>
> Comparing a vaule to null using unequals (\!=) yields false!
> {noformat}
> Map<String, Integer> m = new HashMap<String, Integer>();
> m.put("a", 1);
> m.put("b", null);
> m.put("c", 1);
> JXPathContext c = JXPathContext.newContext(m);
> System.out.println(c.getValue("a != b") + " should be true");
> System.out.println(c.getValue("a != c") + " should be false");
> System.out.println(c.getValue("a = b") + " should be false");
> System.out.println(c.getValue("a = c") + " should be true");
> System.out.println(c.getValue("not(a = b)") + " should be true");
> System.out.println(c.getValue("not(a = c)") + " should be false");
> {noformat}
> Output using 1.3:
> {color:red} false should be true{color}
> false should be false
> false should be false
> true should be true
> true should be true
> false should be false
> In 1.2 it works correctly!
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)