Author: markt Date: Thu Jan 3 15:39:41 2013 New Revision: 1428408 URL: http://svn.apache.org/viewvc?rev=1428408&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54370 Improve handling of nulls when trying to match sets of parameters to a method in EL.
Added: tomcat/tc7.0.x/trunk/test/org/apache/el/util/ - copied from r1428403, tomcat/trunk/test/org/apache/el/util/ Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/el/util/ReflectionUtil.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1428403 Modified: tomcat/tc7.0.x/trunk/java/org/apache/el/util/ReflectionUtil.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/el/util/ReflectionUtil.java?rev=1428408&r1=1428407&r2=1428408&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/el/util/ReflectionUtil.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/el/util/ReflectionUtil.java Thu Jan 3 15:39:41 2013 @@ -250,7 +250,6 @@ public class ReflectionUtil { return match; } - @SuppressWarnings("null") private static Method resolveAmbiguousMethod(Set<Method> candidates, Class<?>[] paramTypes) { // Identify which parameter isn't an exact match @@ -267,6 +266,11 @@ public class ReflectionUtil { } } + if (nonMatchClass == null) { + // Null will always be ambiguous + return null; + } + for (Method c : candidates) { if (c.getParameterTypes()[nonMatchIndex] == paramTypes[nonMatchIndex]) { @@ -294,6 +298,12 @@ public class ReflectionUtil { // src will always be an object private static boolean isAssignableFrom(Class<?> src, Class<?> target) { + // Short-cut. null is always assignable to an object and in EL null + // can always be coerced to a valid value for a primitive + if (src == null) { + return true; + } + Class<?> targetClass; if (target.isPrimitive()) { if (target == Boolean.TYPE) { @@ -334,7 +344,11 @@ public class ReflectionUtil { if (types != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < types.length; i++) { - sb.append(types[i].getName()).append(", "); + if (types[i] == null) { + sb.append("null, "); + } else { + sb.append(types[i].getName()).append(", "); + } } if (sb.length() > 2) { sb.setLength(sb.length() - 2); Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1428408&r1=1428407&r2=1428408&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Jan 3 15:39:41 2013 @@ -92,6 +92,10 @@ <bug>54260</bug>: Avoid <code>NullPointerException</code> when using JSP unloading and tag files. (markt) </fix> + <fix> + <bug>54370</bug>: Improve handling of nulls when trying to match sets of + parameters to a method in EL. (markt) + </fix> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org