Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6FD5510B2E for ; Mon, 3 Feb 2014 07:04:17 +0000 (UTC) Received: (qmail 87948 invoked by uid 500); 3 Feb 2014 07:04:14 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 87523 invoked by uid 500); 3 Feb 2014 07:04:11 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 87389 invoked by uid 99); 3 Feb 2014 07:04:09 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2014 07:04:09 +0000 Date: Mon, 3 Feb 2014 07:04:09 +0000 (UTC) From: "Laurent Malvert (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JXPATH-164) jxpath returns the wrong number of entries if a map contains an empty string value MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JXPATH-164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13889271#comment-13889271 ] Laurent Malvert commented on JXPATH-164: ---------------------------------------- Sorry, originally I meant to report just the last issue, mostly identified by this line in the last test: {code} assertEquals(4, jxp.selectNodes("/.[*]/EMPNO").size()); // should be 14 {code} Then I noticed the issues with the "/*/". I probably should have opened 2 tickets for that. > jxpath returns the wrong number of entries if a map contains an empty string value > ---------------------------------------------------------------------------------- > > Key: JXPATH-164 > URL: https://issues.apache.org/jira/browse/JXPATH-164 > Project: Commons JXPath > Issue Type: Bug > Affects Versions: 1.3, 1.4 > Reporter: Laurent Malvert > > It's a bit of an odd one, but I've noticed the following strange behaviors where JXPath seems to get quite confused when you have an object graph containing maps, where the map contains some objects with an > empty string: > {code} > final JXPathContext jxp = JXPathContext.newContext(ImmutableList.>of( > ImmutableMap.of( > "ID", "1", > "STUFF", "" > ), > ImmutableMap.of( > "ID", "2", > "STUFF", "42" > ), > ImmutableMap.of( > "ID", "3", > "STUFF", "" > ) > )); > assertEquals(3, jxp.selectNodes("ID").size()); > assertEquals(3, jxp.selectNodes("//ID").size()); > assertEquals(3, jxp.selectNodes("/ID").size()); > assertEquals(3, jxp.selectNodes("/.[*]/ID").size()); > assertEquals(1, jxp.selectNodes("/*/ID").size()); // SHOULD RETURN 3 > {code} > Now, if you runt the same test with this: > {code} > final JXPathContext jxp = JXPathContext.newContext(ImmutableList.>of( > ImmutableMap.of( > "ID", "1" > ), > ImmutableMap.of( > "ID", "2" > ), > ImmutableMap.of( > "ID", "3" > ) > )); > assertEquals(3, jxp.selectNodes("ID").size()); > assertEquals(3, jxp.selectNodes("//ID").size()); > assertEquals(3, jxp.selectNodes("/ID").size()); > assertEquals(3, jxp.selectNodes("/.[*]/ID").size()); > assertEquals(0, jxp.selectNodes("/*/ID").size()); // should return 3 > {code} > Notice how that last result is a 0, whereas we got a one in the first test, though the logical structure of the contextbean is the same. > And now for added fun... The odder thing is that I get slightly different behaviors for other seemingly simple datasets. > For instance, consider this data set converted to an object graph: > {noformat} > [ { > "EMPNO" : "7369", > "ENAME" : "SMITH", > "JOB" : "test", > "MGR" : "7902", > "HIREDATE" : "Wed Dec 17 05:00:00 GMT 1980", > "SAL" : "800.0", > "COMM" : "", > "DEPTNO" : "20" > }, { > "EMPNO" : "7499", > "ENAME" : "ALLEN", > "JOB" : "SALESMAN", > "MGR" : "7698", > "HIREDATE" : "Fri Feb 20 05:00:00 GMT 1981", > "SAL" : "1600.0", > "COMM" : "300.0", > "DEPTNO" : "30" > }, { > "EMPNO" : "7521", > "ENAME" : "WARD", > "JOB" : "SALESMAN", > "MGR" : "7698", > "HIREDATE" : "Sun Feb 22 05:00:00 GMT 1981", > "SAL" : "1250.0", > "COMM" : "500.0", > "DEPTNO" : "30" > }, { > "EMPNO" : "7566", > "ENAME" : "JONES", > "JOB" : "MANAGER", > "MGR" : "7839", > "HIREDATE" : "Thu Apr 02 06:00:00 BST 1981", > "SAL" : "2975.0", > "COMM" : "", > "DEPTNO" : "20" > }, { > "EMPNO" : "7654", > "ENAME" : "MARTIN", > "JOB" : "SALESMAN", > "MGR" : "7698", > "HIREDATE" : "Mon Sep 28 05:00:00 BST 1981", > "SAL" : "1250.0", > "COMM" : "1400.0", > "DEPTNO" : "30" > }, { > "EMPNO" : "7698", > "ENAME" : "BLAKE", > "JOB" : "MANAGER", > "MGR" : "7839", > "HIREDATE" : "Fri May 01 05:00:00 BST 1981", > "SAL" : "2850.0", > "COMM" : "", > "DEPTNO" : "30" > }, { > "EMPNO" : "7782", > "ENAME" : "CLARK", > "JOB" : "MANAGER", > "MGR" : "7839", > "HIREDATE" : "Tue Jun 09 05:00:00 BST 1981", > "SAL" : "2450.0", > "COMM" : "", > "DEPTNO" : "10" > }, { > "EMPNO" : "7788", > "ENAME" : "SCOTT", > "JOB" : "ANALYST", > "MGR" : "7566", > "HIREDATE" : "Sun Apr 19 05:00:00 BST 1987", > "SAL" : "3000.0", > "COMM" : "", > "DEPTNO" : "20" > }, { > "EMPNO" : "7839", > "ENAME" : "KING", > "JOB" : "PRESIDENT", > "MGR" : "", > "HIREDATE" : "Tue Nov 17 05:00:00 GMT 1981", > "SAL" : "5000.0", > "COMM" : "", > "DEPTNO" : "10" > }, { > "EMPNO" : "7844", > "ENAME" : "TURNER", > "JOB" : "SALESMAN", > "MGR" : "7698", > "HIREDATE" : "Tue Sep 08 05:00:00 BST 1981", > "SAL" : "1500.0", > "COMM" : "0.0", > "DEPTNO" : "30" > }, { > "EMPNO" : "7876", > "ENAME" : "ADAMS", > "JOB" : "CLERK", > "MGR" : "7788", > "HIREDATE" : "Sat May 23 05:00:00 BST 1987", > "SAL" : "1100.0", > "COMM" : "", > "DEPTNO" : "20" > }, { > "EMPNO" : "7900", > "ENAME" : "JAMES", > "JOB" : "CLERK", > "MGR" : "7698", > "HIREDATE" : "Thu Dec 03 05:00:00 GMT 1981", > "SAL" : "950.0", > "COMM" : "", > "DEPTNO" : "30" > }, { > "EMPNO" : "7902", > "ENAME" : "FORD", > "JOB" : "ANALYST", > "MGR" : "7566", > "HIREDATE" : "Thu Dec 03 05:00:00 GMT 1981", > "SAL" : "3000.0", > "COMM" : "", > "DEPTNO" : "20" > }, { > "EMPNO" : "7934", > "ENAME" : "MILLER", > "JOB" : "CLERK", > "MGR" : "7782", > "HIREDATE" : "Sat Jan 23 05:00:00 GMT 1982", > "SAL" : "1300.0", > "COMM" : "", > "DEPTNO" : "10" > } ] > {noformat} > {code} > final JXPathContext jxp = JXPathContext.newContext(employeeList); > assertEquals(14, jxp.selectNodes("EMPNO").size()); > assertEquals(14, jxp.selectNodes("//EMPNO").size()); > assertEquals(4, jxp.selectNodes("/.[*]/EMPNO").size()); // should be 14 > assertEquals(14, jxp.selectNodes("/EMPNO").size()); > assertEquals(0, jxp.selectNodes("/*/EMPNO").size()); // should also be 14 > {code} > Here we notice that the last result is wrong again as well... but the index based one is wrong as well. And it seems like it's only returning entries where all map values where non-empty. > Not sure if there's something I'm not getting, but it looks like something isn't quite right here. -- This message was sent by Atlassian JIRA (v6.1.5#6160)