-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
(moved from #13334) feat: fix #13327 #13358
base: 3.2
Are you sure you want to change the base?
Conversation
-support custom print stack trace depth -write error message directly into OutputStream
System.setProperty(DUBBO_JSTACK_MAXLINE, depth.toString()); | ||
try (FileOutputStream jStackStream = | ||
new FileOutputStream(new File("/tmp", "Dubbo_JStack.log" + "." + dateStr))) { | ||
jstack(jStackStream); |
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.
Check the result which it print
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.
Added the comparison between the depth printed by the old logic and the new logic. PTAL.
When it traces back to JVMUtil, the line number will be different, making purely comparing two outputs impractical, unless we ignore some lines in the output.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 3.2 #13358 +/- ##
============================================
+ Coverage 69.56% 69.59% +0.02%
Complexity 2 2
============================================
Files 1652 1652
Lines 71608 71609 +1
Branches 10264 10263 -1
============================================
+ Hits 49814 49835 +21
+ Misses 17098 17086 -12
+ Partials 4696 4688 -8 ☔ View full report in Codecov by Sentry. |
try { | ||
byte[] encoded = Files.readAllBytes(Paths.get(String.format("/tmp/%s", filename))); | ||
String newOutput = new String(encoded, StandardCharsets.UTF_8); | ||
int newStackDepth = calculateStackDepth(newOutput); |
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.
Maybe we can decode the stack file with some tools to verify if it match the standard output style.
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 replaced it with ByteArrayOutputStream
to get the result directly, there's no need to decode anymore.
By the way, I tried dumping threads and using the same thread info to generate the stack trace info in both the old way and the new way. Therefore, we can compare the stack trace directly, which turns out to be working correctly.
Optimize logic in JVMUtil to test without writing files while being able to compare the two string outputs directly.
ThreadInfo[] threadInfos = JVMUtil.dumpAllThreads(); | ||
// generate new stack trace info | ||
JVMUtil.jstack(stream, threadInfos); | ||
String newStackTrace = stream.toString(); | ||
// generate old stack trace info | ||
String oldStackTrace = OldJVMUtil.jstack(threadInfos); | ||
// calculate stack trace depth | ||
int newStackDepth = calculateStackDepth(newStackTrace); | ||
int oldStackDepth = calculateStackDepth(oldStackTrace); | ||
|
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 think we need to verify if JVMUtil
work as expected, not work as previous version/
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.
Kudos, SonarCloud Quality Gate passed! |
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.
LGTM
@CrazyHZM PTAL |
Moved from #13334 due to branch operation error.
What is the purpose of the change
fix #13327
dubbo.jstack-dump.max-line
can be used to indicate that all stack trace lines should be printed now by setting it to a negative number, -1 for example.JVMUtilTest
.Brief changelog
org.apache.dubbo.common.utils.JVMUtil
.org.apache.dubbo.common.utils.JVMUtilTest
.AbortPolicyWithReportTest
.Verifying this change
Checklist