-
-
Notifications
You must be signed in to change notification settings - Fork 970
fix 4x exception logging #15564
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
base: 7.1.x
Are you sure you want to change the base?
fix 4x exception logging #15564
Changes from 1 commit
83b22f6
e85c094
ce60438
d1ba16d
90e375e
024b9c8
7678cf4
2963cd9
c68360f
d5d70a6
cbf9f70
c67f460
9c7a7a3
870f9a3
e4c678a
2ba566d
b999949
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,7 +81,7 @@ public Throwable filter(Throwable source, boolean recursive) { | |
| if (recursive) { | ||
| Throwable current = source; | ||
| while (current != null) { | ||
| current = filter(current); | ||
| doFilter(current); | ||
| current = current.getCause(); | ||
| } | ||
| } | ||
|
|
@@ -90,27 +90,38 @@ public Throwable filter(Throwable source, boolean recursive) { | |
|
|
||
| public Throwable filter(Throwable source) { | ||
| if (shouldFilter) { | ||
| StackTraceElement[] trace = source.getStackTrace(); | ||
| List<StackTraceElement> newTrace = filterTraceWithCutOff(trace, cutOffPackage); | ||
|
|
||
| if (newTrace.isEmpty()) { | ||
| // filter with no cut-off so at least there is some trace | ||
| newTrace = filterTraceWithCutOff(trace, null); | ||
| } | ||
|
|
||
| // Only trim the trace if there was some application trace on the stack | ||
| // if not we will just skip sanitizing and leave it as is | ||
| if (!newTrace.isEmpty()) { | ||
| // We don't want to lose anything, so log it | ||
| boolean modified = doFilter(source); | ||
| if (modified) { | ||
| // Log the full stack trace once for the top-level exception (includes causes) | ||
| STACK_LOG.error(FULL_STACK_TRACE_MESSAGE, source); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this a different meaning now? Before it would have been the full stack trace while now it's the filtered. Wouldn't a better solution be to set the logging to trace or something for these detailed stack traces ? Instead of this change why not disable STACK_LOG if you don't want this output?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jdaugherty sensible defaults. logging a stracktrace 4x that has no useful information (especially with the groovy 4 clutter) quickly leads to a scenario where you can run out of disk space fast. I have yet to see an example where the 4x logging provides anything useful. do you have one?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this and we think this should stay with a configuration setting. |
||
| StackTraceElement[] clean = new StackTraceElement[newTrace.size()]; | ||
| newTrace.toArray(clean); | ||
| source.setStackTrace(clean); | ||
| } | ||
|
||
| } | ||
| return source; | ||
| } | ||
|
|
||
| private boolean doFilter(Throwable source) { | ||
| if (!shouldFilter) { | ||
| return false; | ||
| } | ||
| StackTraceElement[] trace = source.getStackTrace(); | ||
| List<StackTraceElement> newTrace = filterTraceWithCutOff(trace, cutOffPackage); | ||
|
|
||
| if (newTrace.isEmpty()) { | ||
| // filter with no cut-off so at least there is some trace | ||
| newTrace = filterTraceWithCutOff(trace, null); | ||
| } | ||
|
|
||
| // Only trim the trace if there was some application trace on the stack | ||
| // if not we will just skip sanitizing and leave it as is | ||
| if (!newTrace.isEmpty()) { | ||
| StackTraceElement[] clean = new StackTraceElement[newTrace.size()]; | ||
| newTrace.toArray(clean); | ||
| source.setStackTrace(clean); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private List<StackTraceElement> filterTraceWithCutOff(StackTraceElement[] trace, String endPackage) { | ||
| List<StackTraceElement> newTrace = new ArrayList<>(); | ||
| boolean foundGroovy = 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.
I noticed that
filter(source)is called again after the cause chain loop. Since the loop already filters thesourcethrowable (whencurrent == source), is the second call on line 89 necessary?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.
@sanjana2505006 that's true about the old code, but after this PR, the early return makes the two calls mutually exclusive now.