-
Notifications
You must be signed in to change notification settings - Fork 98
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
Hide BlockHound's own frame from the Error #62
Conversation
|
||
if ("checkBlocking".equals(stackTraceElement.getMethodName())) { | ||
if (i + 1 < length) { | ||
System.arraycopy(stackTrace, i + 1, stackTrace, 0, length - i - 1); |
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.
this doesn't change the size of the stackTrace
array, leading to duplicated stacktrace elements 💥
verified with strings:
String[] array = new String[] { "A", "B", "C", "D" };
System.arraycopy(array, 2, array, 0, 2);
System.out.println(array.length);
for (String s : array) {
System.out.println(s);
}
prints 4 C D C D
you can probably use Arrays.copyOfRange
, or emulate its core behavior which might perform slightly better (no .class manipulation and no Array.newInstance
):
System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength));
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.
Wow! Great catch 🤦♂
Fixing... 😅
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.
Fixed. Thanks a lot for spotting it! 👍
…mes_from_error # Conflicts: # agent/src/main/java/reactor/blockhound/BlockHound.java
Since we instrument the blocking methods, we add more frames to the stack of the thrown exception. We could artificially remove them from the created
java.lang.Error
instance to not confuse the users with something they do not expect.Before:
After: