jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
60 stars 49 forks source link

Invoking a method using VarArgs with a null value throws an NPE #183

Closed jasmith-hs closed 2 years ago

jasmith-hs commented 2 years ago

In ELUtil.java, when building the parameters for invoking a method, if the final argument of a method is VarArgs and the value is null, then a NullPointerException will be thrown here: https://github.com/jakartaee/expression-language/blob/18bec35a2e5aa73c3aea252880f70472f6de5615/api/src/main/java/jakarta/el/ELUtil.java#L681 Due to params[varArgIndex] being null and null.getClass() cannot be done. A null value for VarArgs in java so something like this seems appropriate:

 if (parameterTypes.length == paramCount && (params[varArgIndex] == null || parameterTypes[varArgIndex] == params[varArgIndex].getClass())) { 
markt-asf commented 2 years ago

Since EL doesn't support casting, a null in that instance is a single argument for the varags which needs to be coerced so the short-cut can't be used. I have a fix for this that I'll commit shortly.