2015-04-28 0:43 GMT+03:00 <[email protected]>:
> Author: markt
> Date: Mon Apr 27 21:43:22 2015
> New Revision: 1676381
>
> URL: http://svn.apache.org/r1676381
> Log:
> Further fix for https://bz.apache.org/bugzilla/show_bug.cgi?id=57855
> Follow-up to r1676231
> Handle case where null is passed to a method with a single varargs parameter
>
> Modified:
> tomcat/trunk/java/org/apache/el/parser/AstValue.java
> tomcat/trunk/test/org/apache/el/TestMethodExpressionImpl.java
> tomcat/trunk/test/org/apache/el/TesterBeanB.java
>
> Modified: tomcat/trunk/java/org/apache/el/parser/AstValue.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstValue.java?rev=1676381&r1=1676380&r2=1676381&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/el/parser/AstValue.java (original)
> +++ tomcat/trunk/java/org/apache/el/parser/AstValue.java Mon Apr 27 21:43:22
> 2015
> @@ -268,9 +268,9 @@ public final class AstValue extends Simp
>
> int paramCount = types.length;
>
> - if (paramCount > 0 && src == null ||
> - m.isVarArgs() && src.length < paramCount ||
> - !m.isVarArgs() && src.length != paramCount) {
> + if (m.isVarArgs() && paramCount > 1 && (src == null || paramCount >
> src.length) ||
> + !m.isVarArgs() && (paramCount > 0 && src == null ||
> + src != null && src.length != paramCount)) {
> String inputParamCount = null;
> if (src != null) {
> inputParamCount = Integer.toString(src.length);
> @@ -286,6 +286,10 @@ public final class AstValue extends Simp
> throw new IllegalArgumentException(msg);
> }
>
> + if (src == null) {
> + return new Object[1];
Did you mean "new Object[0]" here?
Javadoc for Method.invoke() (as linked from comment 5 in BZ) says that
"If the number of formal parameters required by the underlying method
is 0, the supplied args array may be of length 0 or null."
It may be that you need the array if the method is a varargs one (I
have not tested), but if it is not a varargs one then allocating the
array should not be necessary, I guess.
> + }
> +
> Object[] dest = new Object[paramCount];
>
> for (int i = 0; i < paramCount - 1; i++) {
>
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]