commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1215050 - in /commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src: main/java/org/apache/commons/jexl2/internal/MethodExecutor.java test/java/org/apache/commons/jexl2/IssuesTest.java
Date Fri, 16 Dec 2011 07:09:00 GMT
Author: henrib
Date: Fri Dec 16 07:08:59 2011
New Revision: 1215050

URL: http://svn.apache.org/viewvc?rev=1215050&view=rev
Log:
Unfix for JEXL-124, not supposed to happen on RC3 tag!

Modified:
    commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/main/java/org/apache/commons/jexl2/internal/MethodExecutor.java
    commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/test/java/org/apache/commons/jexl2/IssuesTest.java

Modified: commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/main/java/org/apache/commons/jexl2/internal/MethodExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/main/java/org/apache/commons/jexl2/internal/MethodExecutor.java?rev=1215050&r1=1215049&r2=1215050&view=diff
==============================================================================
--- commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/main/java/org/apache/commons/jexl2/internal/MethodExecutor.java
(original)
+++ commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/main/java/org/apache/commons/jexl2/internal/MethodExecutor.java
Fri Dec 16 07:08:59 2011
@@ -134,13 +134,10 @@ public final class MethodExecutor extend
             // and that arg is not the sole argument and not an array of the expected type,
             // make the last arg an array of the expected type
             if (actual[index] != null) {
-                Class<?> aclazz = actual[index].getClass();
-                if (!aclazz.isArray() || !aclazz.getComponentType().equals(type)) {
-                    // create a 1-length array to hold and replace the last argument
-                    Object lastActual = Array.newInstance(type, 1);
-                    Array.set(lastActual, 0, actual[index]);
-                    actual[index] = lastActual;
-                }
+                // create a 1-length array to hold and replace the last argument
+                Object lastActual = Array.newInstance(type, 1);
+                Array.set(lastActual, 0, actual[index]);
+                actual[index] = lastActual;
             }
             // else, the vararg is null and used as is, considered as T[]
         } else {
@@ -179,3 +176,4 @@ public final class MethodExecutor extend
         }
     }
 }
+

Modified: commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/test/java/org/apache/commons/jexl2/IssuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/test/java/org/apache/commons/jexl2/IssuesTest.java?rev=1215050&r1=1215049&r2=1215050&view=diff
==============================================================================
--- commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/test/java/org/apache/commons/jexl2/IssuesTest.java
(original)
+++ commons/proper/jexl/tags/COMMONS_JEXL_2_1-RC3/src/test/java/org/apache/commons/jexl2/IssuesTest.java
Fri Dec 16 07:08:59 2011
@@ -719,21 +719,22 @@ public class IssuesTest extends JexlTest
         s = jexl.createScript("foo.'q u u x'");
         result = s.execute(jc);
         assertEquals("456", result);
-        
+
         Debugger dbg = new Debugger();
         dbg.debug(((ExpressionImpl) s).script);
         String dbgdata = dbg.data();
         assertEquals("foo.'q u u x';", dbgdata);
     }
-        
+
     public static class Container {
         String value0;
         int value1;
+
         public Container(String name, int number) {
             value0 = name;
             value1 = number;
         }
-        
+
         public Object getProperty(String name) {
             if ("name".equals(name)) {
                 return value0;
@@ -743,6 +744,7 @@ public class IssuesTest extends JexlTest
                 return null;
             }
         }
+
         public Object getProperty(int ref) {
             if (0 == ref) {
                 return value0;
@@ -752,24 +754,25 @@ public class IssuesTest extends JexlTest
                 return null;
             }
         }
-        
+
         public void setProperty(String name, String value) {
             if ("name".equals(name)) {
                 this.value0 = value;
             }
-        }  
-        
+        }
+
         public void setProperty(String name, int value) {
             if ("number".equals(name)) {
                 this.value1 = value;
             }
-        }        
+        }
+
         public void setProperty(int ref, String value) {
             if (0 == ref) {
                 this.value0 = value;
             }
-        }  
-        
+        }
+
         public void setProperty(int ref, int value) {
             if (1 == ref) {
                 this.value1 = value;
@@ -782,44 +785,44 @@ public class IssuesTest extends JexlTest
         Container quux = new Container("quux", 42);
         Script get;
         Object result;
-        
+
         Script getName = jexl.createScript("foo.property.name", "foo");
         result = getName.execute(null, quux);
         assertEquals("quux", result);
-        
+
         Script get0 = jexl.createScript("foo.property.0", "foo");
         result = get0.execute(null, quux);
         assertEquals("quux", result);
-        
+
         Script getNumber = jexl.createScript("foo.property.number", "foo");
         result = getNumber.execute(null, quux);
         assertEquals(42, result);
-        
+
         Script get1 = jexl.createScript("foo.property.1", "foo");
         result = get1.execute(null, quux);
         assertEquals(42, result);
-        
+
         Script setName = jexl.createScript("foo.property.name = $0", "foo", "$0");
         setName.execute(null, quux, "QUUX");
         result = getName.execute(null, quux);
         assertEquals("QUUX", result);
         result = get0.execute(null, quux);
         assertEquals("QUUX", result);
-        
+
         Script set0 = jexl.createScript("foo.property.0 = $0", "foo", "$0");
         set0.execute(null, quux, "BAR");
         result = getName.execute(null, quux);
         assertEquals("BAR", result);
         result = get0.execute(null, quux);
         assertEquals("BAR", result);
-        
+
         Script setNumber = jexl.createScript("foo.property.number = $0", "foo", "$0");
         setNumber.execute(null, quux, -42);
         result = getNumber.execute(null, quux);
         assertEquals(-42, result);
         result = get1.execute(null, quux);
         assertEquals(-42, result);
-        
+
         Script set1 = jexl.createScript("foo.property.1 = $0", "foo", "$0");
         set1.execute(null, quux, 24);
         result = getNumber.execute(null, quux);
@@ -827,27 +830,5 @@ public class IssuesTest extends JexlTest
         result = get1.execute(null, quux);
         assertEquals(24, result);
     }
-    
-    public static class Jeff {
-        public String concat(String... strs) {
-            if (strs.length > 0) {
-                StringBuilder strb = new StringBuilder(strs[0]);
-                for(int s = 1; s < strs.length; ++s) {
-                    strb.append(", ");
-                    strb.append(strs[s]);
-                }
-                return strb.toString();
-            } else {
-                return "";
-            }
-            
-        }
-    }
-    
-    public void test124() throws Exception {
-        JexlEngine jexl = new JexlEngine();
-        Script script = jexl.createScript("jeff.concat(['1', '2', '3'])", "jeff");
-        Object res = script.execute(null, new Jeff());
-        assertEquals("1, 2, 3", res);
-    }
+
 }



Mime
View raw message