jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1387999 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast: LengthImpl.java NodeNameImpl.java
Date Thu, 20 Sep 2012 12:50:25 GMT
Author: thomasm
Date: Thu Sep 20 12:50:24 2012
New Revision: 1387999

URL: http://svn.apache.org/viewvc?rev=1387999&view=rev
Log:
OAK-28 Query implementation: upper(x) / lower(x) / length(x) implies x is not null (prevent
NPE)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java?rev=1387999&r1=1387998&r2=1387999&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/LengthImpl.java
Thu Sep 20 12:50:24 2012
@@ -66,22 +66,24 @@ public class LengthImpl extends DynamicO
 
     @Override
     public void restrict(FilterImpl f, Operator operator, CoreValue v) {
-        switch (v.getType()) {
-        case PropertyType.LONG:
-        case PropertyType.DECIMAL:
-        case PropertyType.DOUBLE:
-            // ok - comparison with a number
-            break;
-        case PropertyType.BINARY:
-        case PropertyType.STRING:
-        case PropertyType.DATE:
-            // ok - compare with a string literal
-            break;
-        default:
-            throw new IllegalArgumentException(
-                    "Can not compare the length with a constant of type "
-                            + PropertyType.nameFromValue(v.getType()) +
-                            " and value " + v.toString());
+        if (v != null) {
+            switch (v.getType()) {
+            case PropertyType.LONG:
+            case PropertyType.DECIMAL:
+            case PropertyType.DOUBLE:
+                // ok - comparison with a number
+                break;
+            case PropertyType.BINARY:
+            case PropertyType.STRING:
+            case PropertyType.DATE:
+                // ok - compare with a string literal
+                break;
+            default:
+                throw new IllegalArgumentException(
+                        "Can not compare the length with a constant of type "
+                                + PropertyType.nameFromValue(v.getType()) +
+                                " and value " + v.toString());
+            }
         }
         // LENGTH(x) implies x is not null
         propertyValue.restrict(f, Operator.NOT_EQUAL, null);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java?rev=1387999&r1=1387998&r2=1387999&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NodeNameImpl.java
Thu Sep 20 12:50:24 2012
@@ -68,6 +68,9 @@ public class NodeNameImpl extends Dynami
 
     @Override
     public void restrict(FilterImpl f, Operator operator, CoreValue v) {
+        if (v == null) {
+            return;
+        }
         if (!isName(v)) {
             throw new IllegalArgumentException("Invalid name value: " + v.toString());
         }



Mime
View raw message