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

OGNLContext deprecated constructor crashes #81

Closed
deved65 opened this issue Sep 24, 2019 · 9 comments
Closed

OGNLContext deprecated constructor crashes #81

deved65 opened this issue Sep 24, 2019 · 9 comments

Comments

@deved65
Copy link

deved65 commented Sep 24, 2019

In current release 3.2.11 and master the deprecated constructor public OgnlContext(Map values) in line 117 is unusable and should be removed immediately (or fixed). Currently it will always leads to a NullPointerException in line 170 of the class. To my understanding functionality marked with 'deprecated' should no longer be used (as it will be removed in a future release), but should not be unusable 'by concept'.

@lukaszlenart
Copy link
Collaborator

Are you sure it's about the line 170?

@deved65
Copy link
Author

deved65 commented Sep 26, 2019

Sorry, I messed it up. It is line 140 with a RuntimeException. In line 120 the extensive constructor is invoked with null reference for parameter memberAccess. In line 137 is a null reference check on memberAccess which in turn always must lead to the RuntimeException.

@lukaszlenart
Copy link
Collaborator

The best option I see is to drop that constructor..

@deved65
Copy link
Author

deved65 commented Sep 28, 2019

If no meaningful or 'cheap' default implementation for MemberAccess can be provided I tend to agree.

@lukaszlenart
Copy link
Collaborator

Yeah... that's why I have removed the default implementation from the main code and moved it into tests - it was quite often used to replace a framework's specific implementation by hackers. And that's why OGNL 3.2.x requires to provide your own implementation, even as a copy of the default one based on the one used in tests.

@lukaszlenart
Copy link
Collaborator

Also please be aware that 3.2.x line is still a work-in-progress - maybe I should express that better

@JCgH4164838Gh792C124B5
Copy link
Contributor

Hi.

Dropping the single-argument constructor: https://github.com/jkuhnert/ognl/blob/6de4049f093eb643332bbf14090006fac516393c/src/main/java/ognl/OgnlContext.java#L121 that will now always fail with an exception seems reasonable to me.

At the same time, would it be beneficial to replace the generic RuntimeException exception: https://github.com/jkuhnert/ognl/blob/6de4049f093eb643332bbf14090006fac516393c/src/main/java/ognl/OgnlContext.java#L144
with a more specific IllegalArgumentException instead ?

The updated exception could be something like:

throw new IllegalArgumentException("MemberAccess implementation must be provided - null not permitted!");

@lukaszlenart
Copy link
Collaborator

Good idea, if no objections let's do it :)

JCgH4164838Gh792C124B5 added a commit to JCgH4164838Gh792C124B5/ognl that referenced this issue Feb 23, 2020
- Drops OgnlContext(Map values) constructor that always fails with an
Exception.
- Additional comments for remaining two constructors.
- Changed constructor to ensure _values Map can no longer be null.
- Added comments to setValues(Map value) and getValues() for clarity.
- Added @OverRide annotations to Map interface methods.
lukaszlenart added a commit that referenced this issue Feb 24, 2020
…ue81Fix

Proposed fix for Issue #81 (deprecated constructor always throws an exception)
@lukaszlenart
Copy link
Collaborator

OGNL 3.2.14 is out

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

No branches or pull requests

3 participants