Skip to content

Commit

Permalink
Update DefaultUncaughtExceptionHandler.java
Browse files Browse the repository at this point in the history
Thread dumps are now more complete and can be read by programs expecting a mxbean output.
  • Loading branch information
Gamebuster19901 authored Sep 25, 2024
1 parent cc6c5f1 commit 728af65
Showing 1 changed file with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,13 @@ public void dumpThreads(boolean dumpThreads) {
}

protected static String dump() {
StringBuilder text = new StringBuilder();
ThreadMXBean threads = ManagementFactory.getThreadMXBean();
ThreadInfo[] dumps = threads.getThreadInfo(threads.getAllThreadIds(), 255);
text.append("====THREAD DUMP====\n\n");
for (ThreadInfo dump : dumps) {
text.append("\"").append(dump.getThreadName()).append("\"\n");
Thread.State state = dump.getThreadState();
text.append("\tState: ").append(state);
String blockedBy = dump.getLockOwnerName();
if (blockedBy != null) {
text.append(" on ").append(blockedBy);
}
text.append("\n");
StackTraceElement[] elements = dump.getStackTrace();
for (StackTraceElement element : elements) {
text.append("\t\tat ");
text.append(element);
text.append("\n");
}
text.append("\n\n");
}
return text.toString();
StringBuilder text = new StringBuilder();
ThreadMXBean threads = ManagementFactory.getThreadMXBean();
text.append("---- THREAD DUMP ----\n\n");
for (ThreadInfo dump : threads.dumpAllThreads(true, true)) {
text.append(dump.toString());
}
return text.toString();
}

protected static String getSystemInfo() {
Expand Down

0 comments on commit 728af65

Please sign in to comment.