MCPcopy Create free account
hub / github.com/apache/tomcat / getThreadDump

Method getThreadDump

java/org/apache/tomcat/util/Diagnostics.java:306–341  ·  view source on GitHub ↗

Formats the thread dump for one thread. @param ti the ThreadInfo describing the thread @return the formatted thread dump

(ThreadInfo ti)

Source from the content-addressed store, hash-verified

304 * @return the formatted thread dump
305 */
306 private static String getThreadDump(ThreadInfo ti) {
307 StringBuilder sb = new StringBuilder(getThreadDumpHeader(ti));
308 for (LockInfo li : ti.getLockedSynchronizers()) {
309 sb.append(INDENT2 + "locks ").append(li.toString()).append(CRLF);
310 }
311 boolean start = true;
312 StackTraceElement[] stes = ti.getStackTrace();
313 Object[] monitorDepths = new Object[stes.length];
314 MonitorInfo[] mis = ti.getLockedMonitors();
315 for (MonitorInfo monitorInfo : mis) {
316 monitorDepths[monitorInfo.getLockedStackDepth()] = monitorInfo;
317 }
318 for (int i = 0; i < stes.length; i++) {
319 StackTraceElement ste = stes[i];
320 sb.append(INDENT2 + "at ").append(ste.toString()).append(CRLF);
321 if (start) {
322 if (ti.getLockName() != null) {
323 sb.append(INDENT2 + "- waiting on (a ").append(ti.getLockName()).append(")");
324 if (ti.getLockOwnerName() != null) {
325 sb.append(" owned by ").append(ti.getLockOwnerName()).append(" Id=")
326 .append(ti.getLockOwnerId());
327 }
328 sb.append(CRLF);
329 }
330 start = false;
331 }
332 if (monitorDepths[i] != null) {
333 MonitorInfo mi = (MonitorInfo) monitorDepths[i];
334 sb.append(INDENT2 + "- locked (a ").append(mi.toString()).append(")").append(" index ");
335 sb.append(mi.getLockedStackDepth()).append(" frame ").append(mi.getLockedStackFrame().toString());
336 sb.append(CRLF);
337
338 }
339 }
340 return sb.toString();
341 }
342
343 /**
344 * Formats the thread dump for a list of threads.

Callers 2

findDeadlockMethod · 0.95
threadDumpMethod · 0.95

Calls 9

getThreadDumpHeaderMethod · 0.95
getManagerMethod · 0.95
findDeadlockMethod · 0.95
toStringMethod · 0.65
formatMethod · 0.65
getStringMethod · 0.65
getPropertyMethod · 0.65
appendMethod · 0.45
getStackTraceMethod · 0.45

Tested by

no test coverage detected