On 27/04/2015 23:10, Christopher Schultz wrote: > Konstantin, > > On 4/27/15 6:06 PM, Konstantin Kolinko wrote: >> 2015-04-28 0:43 GMT+03:00 <ma...@apache.org>: >>> 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?
No. It needs to be Object[1] since it must be a varags method with a single parameter and the size of the array has to match the number of formal parameters. >> 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. If the method isn't varargs and src == null it will never reach this point. > ... and if it can be "new Object[0]" then you can re-use the same > zero-length array for all such calls if you want to avoid an object > allocation. There are a couple of places where I could add that. Thanks for the review. Commit to follow shortly. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org