-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Avoid collecting stacktrace when building an OgnlException [Fixes OGNL-261] #138
Conversation
@harawata @quaff @JCgH4164838Gh792C124B5 could you take a look on this PR? |
Hello @davoustp @lukaszlenart ! Does this mean we lose some information that can be useful when investigating an issue? |
_initCause.invoke(this, new Object[] { reason }); | ||
} catch (Exception t) { /** ignore */ } | ||
} | ||
super( msg , reason, true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be controllable from outside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's was the point of my question about the way to control this behavior change using whatever configuration mechanism is available.
Sorry that I was not clear enough. :-/
Personally, I would add a java prop and initialize a static boolean in OgnlContext
(mimicking what's already done) to allow the user to control whether the stacktraces are collected when throwing OgnlException
s or not.
This would allow to cope for unexpected situations when the previous behavior is actually required.
However, since OgnlContext
is not already provided in any of the OgnlException
constructor methods, this would stay a JVM-wide setting (meaning you would not be able to control this per OGNL evaluation).
Adding the OgnlContext
and changing all code paths throwing this exception looks overkill to me.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that you can decide when creating the exception to collect or not the stack trace. I would just add another constructor and expose these true, false
s and that's all :)
Then we can extend your idea and use OgnlContext
to control if the exception should be created with stack trace or note (delegate the control out of exception itself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! Indeed, we can add the signature from java.lang.Exception.Exception(String, Throwable, boolean, boolean)
No big deal, I'll do it right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I'll leave this new constructor protected
as this is intended to be used by sub-classes and not by code path throwing the exception - see java.lang.Throwable.Throwable(String, Throwable, boolean, boolean)
.
Makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, makes sense 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and pushed.
Hi @harawata
It depends. If a cause exception is provided when building the When raised by If this is a problem, then that's why I asked if a configuration switch would be required (on or off by default, whatever you think is best - either maintain the previous behavior or go for the new behavior by default).
You can use There is currently no test around |
BTW, I'm wondering about the two |
Added protected method to allow control on exception suppression and stacktrace collections to sub-classes.
Any objection against removal of these |
I think it's ok to remove them |
Remove printStackTrace overrides as this is now handled by base class already. Fixed typo in protected constructor's javadoc
Done. |
I will release this changes as 3.4.x and also officially announce switching to Java 8 (I thought I already did that) |
Thank you for the explanation @davoustp , |
Hello @lukaszlenart , @davoustp , and @harawata . Thanks for including me in the discussion. :) Also, thanks for the detailed explanation behind the changes, @davoustp . After reviewing the changes for the PR, it looks like maybe some of the old code logic might have been intended to handle pre-JDK 1.4 conditions, but I could be mistaken ? The the only potential risk that I could see with the It looks like the changes preserve the exception reason/cause via the "normal" Other than that, there are two additional comments related to the discussion above:
|
You're welcome. The better a change is understood, the more accepted it gets, in my opinion. ;-)
I suppose you refer to the
About:
I'm not sure what you mean here. I don't see any way to have this method to "skip" printing the cause |
Yeah, it would be good to address this split personality and just keep one OGNL repository - I was planning move some changes from this repo into commons-ognl but this looks like overwhelming task, also preparing a release under ASF Commons is more complicated than here. So I was thinking about closing commons-ognl and keep supporting future of OGNL only here.
Yes & no - I missed that I had already switched to Java 8 but didn't push a new release, a few days ago I have released a new 3.3.0 version with Java 8 requirement and some fix. This change can be included in 3.3.1 or as a breaking change it can be included in 3.4.x. And I don't want to create dedicated branches if not needed, it's very hard to keep them in sync. |
Hi @davoustp .
Ooops ... I missed the fact that the standard Since your changes set the Thanks for your work on this PR, @davoustp. After the discussion, it looks good to me. 👍 |
@JCgH4164838Gh792C124B5 you're welcome! |
LGTM and released, thanks @davoustp @harawata and @JCgH4164838Gh792C124B5 for the review and discussion 💪 |
No description provided.