From e6f5b5971db91b7dc3e164876693f68df2b118dd Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Wed, 9 Jun 2021 14:55:09 +0800 Subject: [PATCH] fix trace command may not print result problem. #1817 --- .../command/monitor200/AbstractTraceAdviceListener.java | 7 +++++-- .../arthas/core/command/monitor200/TraceEntity.java | 8 -------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/AbstractTraceAdviceListener.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/AbstractTraceAdviceListener.java index 300d7dfb7..023d03da7 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/AbstractTraceAdviceListener.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/AbstractTraceAdviceListener.java @@ -81,8 +81,11 @@ public class AbstractTraceAdviceListener extends AdviceListenerAdapter { private void finishing(ClassLoader loader, Advice advice) { // 本次调用的耗时 TraceEntity traceEntity = threadLocalTraceEntity(loader); - double cost = threadLocalWatch.costInMillis(); - if (--traceEntity.deep == 0) { + if (traceEntity.deep >= 1) { // #1817 防止deep为负数 + traceEntity.deep--; + } + if (traceEntity.deep == 0) { + double cost = threadLocalWatch.costInMillis(); try { boolean conditionResult = isConditionMet(command.getConditionExpress(), advice, cost); if (this.isVerbose()) { diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceEntity.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceEntity.java index c2e1ecbf9..3cc2a4b5a 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceEntity.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/TraceEntity.java @@ -18,14 +18,6 @@ public class TraceEntity { this.deep = 0; } - public int getDeep() { - return deep; - } - - public void setDeep(int deep) { - this.deep = deep; - } - private TraceTree createTraceTree(ClassLoader loader) { return new TraceTree(ThreadUtil.getThreadNode(loader, Thread.currentThread())); }