-
Notifications
You must be signed in to change notification settings - Fork 543
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
[SUREFIRE-1851] Prevent NPE in SmartStackTraceParser #320
[SUREFIRE-1851] Prevent NPE in SmartStackTraceParser #320
Conversation
} | ||
|
||
@Override | ||
public synchronized Throwable getCause() |
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.
Why synchronized
?
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.
There is no need for it to be synchronized, good catch. I will remove this.
Pls squash the commits finally. Thx. |
} | ||
|
||
private static List<StackTraceElement> focusOnClass( StackTraceElement[] stackTrace, Class<?> clazz ) | ||
{ | ||
List<StackTraceElement> result = new ArrayList<>(); | ||
if ( stackTrace == null ) | ||
{ |
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.
Pls use Collections.emptyList()
instead, and move the ArrayList
down. Thx
Many thanks for your review 🙌 I believe I have made the required changes, including:
|
Thx, lets continue tomorrow morning.
Dňa st 7. 10. 2020, 1:37 Adam Jones <notifications@github.com> napísal(a):
… Many thanks for your review 🙌
I believe I have made the required changes, including:
- removing unnecessary synchronized
- squashing the commits into one final commit (0505338
<0505338>
)
- moving the array list constructor past the if statement, and using
Collections.emptyList() instead
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#320 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH7ER2U5XOEAX5YWHX7LATSJOS43ANCNFSM4SEBPILA>
.
|
@domdomegg |
Thanks for your review and help with this :) |
JIRA: https://issues.apache.org/jira/browse/SUREFIRE-1851
SmartStackTraceParser is used in various places to parse throwables. However, if the throwable stack trace is null it will throw an NPE itself. This can cause test runners to fail in unexpected ways, which in the worst case can lead to false success test results and passing builds despite the test actually failing.
An exception with a null stacktrace sounds odd, but is easy to do by mocking an exception with frameworks like Mockito. While people probably shouldn't be mocking exceptions, it definitely can and does happen. Can be reproduced with https://github.com/domdomegg/surefire-1851-demo
This is my first PR to the Apache project, apologies if I've gotten anything wrong - I've tried to follow the contributing guidelines as best I can, but do let me know if something needs changing :)