Skip to content
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

SpEL cannot evaluate after update from 6.0.13 to 6.1.1 #31666

Closed
piotrooo opened this issue Nov 24, 2023 · 1 comment
Closed

SpEL cannot evaluate after update from 6.0.13 to 6.1.1 #31666

piotrooo opened this issue Nov 24, 2023 · 1 comment
Labels
status: invalid An issue that we don't feel is valid

Comments

@piotrooo
Copy link

Affects: 6.1.1


In version 6.0.13 following repro works:

@Test
void should() throws Exception {
    TestSpel testSpel = new TestSpel();

    DefaultParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
    SpelExpression expression = new SpelExpressionParser().parseRaw("#parameter.value()");

    Method method1 = testSpel.getClass().getDeclaredMethod("method1", RecordParameter.class);
    Object[] parameters1 = new Object[]{new RecordParameter("testing record")};
    MethodBasedEvaluationContext context1 = new MethodBasedEvaluationContext(testSpel, method1, parameters1, parameterNameDiscoverer);

    Object value1 = expression.getValue(context1);

    assertThat(value1).isEqualTo("testing record");
}

static class TestSpel {
    void method1(RecordParameter parameter) {
    }
}

record RecordParameter(String value) {
}

After bump to 6.1.1 following exception is thrown:

org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method value() on null context object

	at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:166)
	at org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:95)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:76)
	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:97)
	at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:114)
	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:273)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 24, 2023
@snicoll
Copy link
Member

snicoll commented Nov 24, 2023

In version 6.0.13 following repro works:

Make sure that you compile your code with -parameters, see the second paragraph of this section of the upgrade notes. And you should have seen a warning in the logs stating as much with 6.0.x.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2023
@snicoll snicoll added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants