Author: remy.maucherat(a)jboss.com
Date: 2013-01-04 07:27:10 -0500 (Fri, 04 Jan 2013)
New Revision: 2144
Modified:
branches/7.2.x/src/main/java/org/apache/el/util/ReflectionUtil.java
branches/7.2.x/webapps/docs/changelog.xml
Log:
AS7-3177: Improved null parameter mapping fix.
Modified: branches/7.2.x/src/main/java/org/apache/el/util/ReflectionUtil.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/el/util/ReflectionUtil.java 2013-01-03
01:27:41 UTC (rev 2143)
+++ branches/7.2.x/src/main/java/org/apache/el/util/ReflectionUtil.java 2013-01-04
12:27:10 UTC (rev 2144)
@@ -249,7 +249,6 @@
return match;
}
- @SuppressWarnings("null")
private static Method resolveAmbiguousMethod(Set<Method> candidates,
Class<?>[] paramTypes) {
// Identify which parameter isn't an exact match
@@ -266,6 +265,11 @@
}
}
+ if (nonMatchClass == null) {
+ // Null will always be ambiguous
+ return null;
+ }
+
for (Method c : candidates) {
if (c.getParameterTypes()[nonMatchIndex] ==
paramTypes[nonMatchIndex]) {
@@ -293,6 +297,12 @@
// 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) {
@@ -333,7 +343,11 @@
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: branches/7.2.x/webapps/docs/changelog.xml
===================================================================
--- branches/7.2.x/webapps/docs/changelog.xml 2013-01-03 01:27:41 UTC (rev 2143)
+++ branches/7.2.x/webapps/docs/changelog.xml 2013-01-04 12:27:10 UTC (rev 2144)
@@ -22,6 +22,9 @@
<fix>
<bug>35410</bug>: Revert bugfix working around a null toString().
(markt)
</fix>
+ <fix>
+ <bug>54370</bug>: NPE fix for EL method mapping with null
parameters. (markt, remm)
+ </fix>
</changelog>
</subsection>
</section>
Show replies by date