jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sch...@apache.org
Subject svn commit: r1393342 - in /jackrabbit/trunk/jackrabbit-spi-commons/src: main/java/org/apache/jackrabbit/spi/commons/query/xpath/ test/java/org/apache/jackrabbit/spi/commons/query/xpath/
Date Wed, 03 Oct 2012 08:25:42 GMT
Author: schans
Date: Wed Oct  3 08:25:42 2012
New Revision: 1393342

URL: http://svn.apache.org/viewvc?rev=1393342&view=rev
Log:
JCR-3435: Fix NPE for xpath query with child axis and star name

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=1393342&r1=1393341&r2=1393342&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
Wed Oct  3 08:25:42 2012
@@ -348,7 +348,7 @@ class QueryFormat implements QueryNodeVi
             PathQueryNode relPath = node.getRelativePath();
             if (relPath == null) {
                 propPath.append(".");
-            } else if (relPath.getNumOperands() > 0 && relPath.getPathSteps()[0].getNameTest().equals(XPathQueryBuilder.FN_POSITION_FULL))
{
+            } else if (relPath.getNumOperands() > 0 && XPathQueryBuilder.FN_POSITION_FULL.equals(relPath.getPathSteps()[0].getNameTest()))
{
                 propPath.append(resolver.getJCRName(XPathQueryBuilder.FN_POSITION_FULL));
             } else {
                 LocationStepQueryNode[] steps = relPath.getPathSteps();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java?rev=1393342&r1=1393341&r2=1393342&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/XPathQueryBuilder.java
Wed Oct  3 08:25:42 2012
@@ -425,8 +425,13 @@ public class XPathQueryBuilder implement
                         }
                         PathQueryNode relPath = tmp.getRelativePath();
                         LocationStepQueryNode[] steps = relPath.getPathSteps();
-                        
-                        tmpRelPath.addLast(steps[steps.length-1].getNameTest());
+
+                        Name nameTest = steps[steps.length-1].getNameTest();
+                        if (nameTest==null) {
+                        	// see LocationStepQueryNode javadoc on when getNameTest()==null:
when it was a star (asterisk)
+                        	nameTest = RelationQueryNode.STAR_NAME_TEST;
+                        }
+						tmpRelPath.addLast(nameTest);
                     }
                 }
                 break;
@@ -956,7 +961,7 @@ public class XPathQueryBuilder implement
                     }
                     if (queryNode.getType() == QueryNode.TYPE_PATH) {
                         PathQueryNode pathNode = (PathQueryNode) queryNode;
-                        
+
                         pathNode.addPathStep(createDerefQueryNode(node, descendant, pathNode));
                     } else if (queryNode.getType() == QueryNode.TYPE_RELATION) {
                         RelationQueryNode relNode = (RelationQueryNode) queryNode;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java?rev=1393342&r1=1393341&r2=1393342&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
Wed Oct  3 08:25:42 2012
@@ -67,6 +67,14 @@ public class QueryFormatTest extends Tes
         checkStatement("//element(*, foo)[foo/*/@bar = 'bla']");
     }
 
+    public void testStarNameAtBeginningOfPredicate() throws Exception {
+        checkStatement("//element(*, foo)[*/*/@bar = 'bla']");
+    }
+
+    public void testChildStarName() throws Exception {
+        checkStatement("//programs//*[*/@sunday]");
+    }
+
     public void testRepSimilar() throws Exception {
         checkStatement("//element(*, foo)[rep:similar(foo, '/some/path')]");
     }



Mime
View raw message