Re: svn commit: r1214986 - 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

2011-12-16 Thread sebb
On 16 December 2011 07:26, henrib  wrote:
> Should not commit that late...
> Reverted RC3, applied fix on 2.0 branch.
> Thanks for catching this!

I always use http: rather than https: when checking out tags - avoids accidents.

> --
> View this message in context: 
> http://apache-commons.680414.n4.nabble.com/Re-svn-commit-r1214986-in-commons-proper-jexl-tags-COMMONS-JEXL-2-1-RC3-src-main-java-org-apache-coma-tp4202553p4203622.html
> Sent from the Commons - Dev mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>

-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: svn commit: r1214986 - 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

2011-12-15 Thread henrib
Should not commit that late...
Reverted RC3, applied fix on 2.0 branch.
Thanks for catching this!

--
View this message in context: 
http://apache-commons.680414.n4.nabble.com/Re-svn-commit-r1214986-in-commons-proper-jexl-tags-COMMONS-JEXL-2-1-RC3-src-main-java-org-apache-coma-tp4202553p4203622.html
Sent from the Commons - Dev mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



Re: svn commit: r1214986 - 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

2011-12-15 Thread sebb
On 15 December 2011 23:10,   wrote:
> Author: henrib
> Date: Thu Dec 15 23:10:21 2011
> New Revision: 1214986
>
> URL: http://svn.apache.org/viewvc?rev=1214986&view=rev
> Log:
> Fix for JEXL-124
>
> 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

-1

This needs to be reverted immediately - fixes should never be applied
to tags, which are supposed to be immutable

The fix needs to be applied to branch-2.0 instead.

> 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=1214986&r1=1214985&r2=1214986&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
>  Thu Dec 15 23:10:21 2011
> @@ -27,6 +27,7 @@ import org.apache.commons.jexl2.internal
>  public final class MethodExecutor extends AbstractExecutor.Method {
>     /** Whether this method handles varargs. */
>     private final boolean isVarArgs;
> +
>     /**
>      * Creates a new instance.
>      * @param is the introspector used to discover the method
> @@ -49,7 +50,7 @@ public final class MethodExecutor extend
>      */
>     @Override
>     public Object execute(Object o, Object[] args)
> -        throws IllegalAccessException, InvocationTargetException  {
> +            throws IllegalAccessException, InvocationTargetException {
>         if (isVarArgs) {
>             Class[] formal = method.getParameterTypes();
>             int index = formal.length - 1;
> @@ -83,7 +84,6 @@ public final class MethodExecutor extend
>         return TRY_FAILED;
>     }
>
> -
>     /**
>      * Discovers a method for a {@link MethodExecutor}.
>      * 
> @@ -131,12 +131,16 @@ public final class MethodExecutor extend
>         // if no values are being passed into the vararg, size == 0
>         if (size == 1) {
>             // if one non-null value is being passed into the vararg,
> +            // 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) {
> -                // 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;
> +                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;
> +                }
>             }
>             // else, the vararg is null and used as is, considered as T[]
>         } else {
> @@ -158,7 +162,7 @@ public final class MethodExecutor extend
>         return actual;
>     }
>
> -   /**
> +    /**
>      * Determines if a method can accept a variable number of arguments.
>      * @param m a the method to check
>      * @return true if method is vararg, false otherwise
> @@ -175,5 +179,3 @@ 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=1214986&r1=1214985&r2=1214986&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
>  Thu Dec 15 23:10:21 2011
> @@ -827,4 +827,27 @@ 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(", ");
> +