Skip to content

SPEL: Unable to pass null values to method calls [SPR-5899] #10568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 6, 2009 · 1 comment
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 6, 2009

Oliver Becker opened SPR-5899 and commented

This is a follow-up of #10332

The bugfix treats all null values as of type java.lang.Object (line 90 in org.springframework.expression.spel.ast.MethodReference). Unfortunately Spring can't find a matching method in this case, because generally Object can't be converted to any other type.

Simple example:

public class NullMethodParamConverterBug {

public Integer tryToInvokeWithNull(Integer value) {
    return value;
}

}

and

#{nullMethodParamConverterBug.tryToInvokeWithNull(null)}

causes

org.springframework.expression.spel.SpelException: EL1003E:(pos 28): Method call: Method tryToInvokeWithNull(java.lang.Object) cannot be found on NullMethodParamConverterBug type
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:130)
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:76)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:54)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:51)
at org.springframework.expression.spel.SpelExpression.getValue(SpelExpression.java:66)


Affects: 3.0 M3

Referenced from: commits eb69e75

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

Test and fix committed, supports passing null to methods or constructors and allows for varargs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants