File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
common/src/main/java/org/embeddedt/modernfix/world Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 55import java .lang .management .ThreadMXBean ;
66
77public class ThreadDumper {
8+ private static final String STACKTRACE_TAIL = "\t ...\n \n " ;
89 public static String obtainThreadDump () {
910 ThreadMXBean threadmxbean = ManagementFactory .getThreadMXBean ();
1011 ThreadInfo [] athreadinfo = threadmxbean .dumpAllThreads (true , true );
1112 StringBuilder sb = new StringBuilder ();
1213 sb .append ("Thread Dump:\n " );
1314 for (ThreadInfo threadinfo : athreadinfo ) {
14- sb . append ( threadinfo );
15+ String tInfo = threadinfo . toString ( );
1516 StackTraceElement [] elements = threadinfo .getStackTrace ();
1617 if (elements .length > 8 ) {
17- sb .append ("extended trace:\n " );
18+ if (tInfo .endsWith (STACKTRACE_TAIL ))
19+ tInfo = tInfo .substring (0 , tInfo .length () - STACKTRACE_TAIL .length ());
20+ else
21+ tInfo = tInfo + "extended trace:\n " ;
22+ }
23+ sb .append (tInfo );
24+ if (elements .length > 8 ) {
1825 for (int i = 8 ; i < elements .length ; i ++) {
1926 sb .append ("\t at " );
2027 sb .append (elements [i ]);
You can’t perform that action at this time.
0 commit comments