diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadCommand.java index 2ef0db2383..df8fbf4fe1 100755 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ThreadCommand.java @@ -212,8 +212,10 @@ private ExitStatus processTopBusyThreads(CommandProcess process) { List busyThreadInfos = new ArrayList(topNThreads.size()); for (ThreadVO thread : topNThreads) { ThreadInfo threadInfo = findThreadInfoById(threadInfos, thread.getId()); - BusyThreadInfo busyThread = new BusyThreadInfo(thread, threadInfo); - busyThreadInfos.add(busyThread); + if (threadInfo != null) { + BusyThreadInfo busyThread = new BusyThreadInfo(thread, threadInfo); + busyThreadInfos.add(busyThread); + } } process.appendResult(new ThreadModel(busyThreadInfos)); return ExitStatus.success(); diff --git a/core/src/main/java/com/taobao/arthas/core/util/ThreadUtil.java b/core/src/main/java/com/taobao/arthas/core/util/ThreadUtil.java index b709857cb7..945194ae84 100644 --- a/core/src/main/java/com/taobao/arthas/core/util/ThreadUtil.java +++ b/core/src/main/java/com/taobao/arthas/core/util/ThreadUtil.java @@ -266,6 +266,9 @@ public static String getFullStacktrace(ThreadInfo threadInfo, double cpuUsage, l } public static String getFullStacktrace(BusyThreadInfo threadInfo, int lockIdentityHashCode, int blockingThreadCount) { + if (threadInfo == null) { + return ""; + } StringBuilder sb = new StringBuilder("\"" + threadInfo.getName() + "\""); if (threadInfo.getId() > 0) { sb.append(" Id=").append(threadInfo.getId());