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

EL1072E when evaluating compiled null-safe expression [SPR-16489] #21032

Closed
spring-projects-issues opened this issue Feb 13, 2018 · 10 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Juan Domínguez González opened SPR-16489 and commented

When evaluating an expression involving a null-safe access to a field it fails when using the bytecode compiled expression.

Can be reproduced using the attached test case.

The problem could reside in class PropertyOrFieldReference. Its readProperty method (used when evaluating in interpreted mode), takes into account the nullSafe field, however its generateCode method doesn't use the nullSafe field. It seems that generateCode method could append bytecodes for null-checking the context object, as in the interpreted version.


Affects: 4.3.14

Attachments:

Referenced from: commits 1db7e02, d3acf45

Backported to: 4.3.16

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

I think Juan is right about where the changes are needed but as usual when issues arise with the expression compilation I like to explore all related corner cases. This also needs addressing for nullsafe method references, with a similar fix. But the fix isn't just a couple of lines because we have to take into account that the method/property/field may result in a primitive and in that case we have to do a few extra gymnastics to handle the nullsafe case. We want it to give the same result as an interpreted case.

@spring-projects-issues
Copy link
Collaborator Author

Juan Domínguez González commented

Just a suggestion: since a null-check can be expressed with a ternary operator, I'd seek "inspiration" in class org.springframework.expression.spel.ast.Ternary.

Its generateCode method also takes into account primitives; I don't know if its handling is suitable for the nullsafe case.

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

Pushed changes for this to work, with new testcases for the property and method cases.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Thanks, Andy - I'll mark this as resolved then...

@spring-projects-issues
Copy link
Collaborator Author

Juan Domínguez González commented

Hi.

I've downloaded version 4.3.15 of spring-expression.

Seems that the fix for this bug has'n been included in that version. Should'n have been included?

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

It was fixed in 5.0 line, not sure the change was pulled across to the 4.3.x line though, looks like we missed doing that.

@spring-projects-issues
Copy link
Collaborator Author

Andy Clement commented

Backported to 4.3.x branch for 4.3.16 inclusion.

@spring-projects-issues
Copy link
Collaborator Author

Juan Domínguez González commented

I've seen that version 4.3.16 was released just yesterday. Didn't expect it so soon.

Thanks!

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Neither did we... but since we missed another backport as well, unfortunately part of a CVE resolution, we escalated the release.

@spring-projects-issues
Copy link
Collaborator Author

Juan Domínguez González commented

We've been lucky, then. Thanks, anyway!

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants