cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r604601 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/exp/parser/SimpleNode.java test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
Date Sun, 16 Dec 2007 10:37:40 GMT
Author: aadamchik
Date: Sun Dec 16 02:37:39 2007
New Revision: 604601

URL: http://svn.apache.org/viewvc?rev=604601&view=rev
Log:
CAY-941 NPE in SimpleNode.connectChildren()
(while 3.0 is not affected, I still added a unit test and a null check for extra robustness)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/SimpleNode.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/SimpleNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/SimpleNode.java?rev=604601&r1=604600&r2=604601&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/SimpleNode.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/parser/SimpleNode.java
Sun Dec 16 02:37:39 2007
@@ -280,7 +280,11 @@
     protected void connectChildren() {
         if (children != null) {
             for (int i = 0; i < children.length; i++) {
-                children[i].jjtSetParent(this);
+                // although nulls are expected to be wrapped in scalar, still doing a
+                // check here to make it more robust
+                if (children[i] != null) {
+                    children[i].jjtSetParent(this);
+                }
             }
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java?rev=604601&r1=604600&r2=604601&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/exp/ExpressionFactoryTest.java
Sun Dec 16 02:37:39 2007
@@ -151,7 +151,7 @@
     }
 
     public void testInExp2() throws Exception {
-        List v = new ArrayList();
+        List<Object> v = new ArrayList<Object>();
         v.add("a");
         v.add("b");
         Expression exp = ExpressionFactory.inExp("abc", v);
@@ -159,7 +159,7 @@
     }
 
     public void testInExp3() throws Exception {
-        List v = new ArrayList();
+        List<Object> v = new ArrayList<Object>();
         Expression exp = ExpressionFactory.inExp("abc", v);
         assertEquals(Expression.FALSE, exp.getType());
     }
@@ -204,5 +204,15 @@
         String v = "abc";
         Expression exp = ExpressionFactory.notLikeIgnoreCaseExp("abc", v);
         assertEquals(Expression.NOT_LIKE_IGNORE_CASE, exp.getType());
+    }
+    
+    // testing CAY-941 bug
+    public void testLikeExpNull() throws Exception {
+        Expression exp = ExpressionFactory.likeExp("abc", null);
+        assertEquals(Expression.LIKE, exp.getType());
+
+        Expression path = (Expression) exp.getOperand(0);
+        assertEquals(Expression.OBJ_PATH, path.getType());
+        assertNull(exp.getOperand(1));
     }
 }



Mime
View raw message