From 4ebab8f263c8316df3f1f527b4de94ed25a3af07 Mon Sep 17 00:00:00 2001 From: wxm <115806199+youfanx@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:40:32 +0800 Subject: [PATCH] up --- rxlib/src/main/java/org/rx/core/Constants.java | 3 +++ rxlib/src/main/java/org/rx/core/ThreadPool.java | 6 +++--- rxlib/src/main/java/org/rx/exception/TraceHandler.java | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/rxlib/src/main/java/org/rx/core/Constants.java b/rxlib/src/main/java/org/rx/core/Constants.java index ddff6d5d..778329ee 100644 --- a/rxlib/src/main/java/org/rx/core/Constants.java +++ b/rxlib/src/main/java/org/rx/core/Constants.java @@ -49,6 +49,9 @@ enum MetricName { String CACHE_REGION_BEAN_PROPERTIES = "PROP"; String CACHE_REGION_INTERFACE_METHOD = "IM"; String CACHE_REGION_SKIP_SERIALIZE = "SS"; + + String STACK_TRACE_FLAG = "\nat "; + /** * do not edit */ diff --git a/rxlib/src/main/java/org/rx/core/ThreadPool.java b/rxlib/src/main/java/org/rx/core/ThreadPool.java index 6fb7594b..8c96bd99 100644 --- a/rxlib/src/main/java/org/rx/core/ThreadPool.java +++ b/rxlib/src/main/java/org/rx/core/ThreadPool.java @@ -167,7 +167,7 @@ static Task as(Object fn) { final Object id; final InternalThreadLocalMap parent; final String traceId; - final Class caller; + final Class[] caller; private Task(Func fn, FlagsEnum flags, Object id) { if (flags == null) { @@ -179,7 +179,7 @@ private Task(Func fn, FlagsEnum flags, Object id) { } if (conf.trace.slowMethodElapsedMicros > 0) { //Reflects.getStackTrace(t) - caller = Reflects.CLASS_TRACER.getClassTrace(0); + caller = Reflects.CLASS_TRACER.getClassTrace(); } else { caller = null; } @@ -205,7 +205,7 @@ public T call() { throw e; } finally { Thread t = Thread.currentThread(); - TraceHandler.INSTANCE.saveMethodTrace(t, ifNull(caller, ThreadPool.class), fn.getClass().getSimpleName(), id == null ? null : new Object[]{id}, + TraceHandler.INSTANCE.saveMethodTrace(t, caller != null ? caller[0] : ThreadPool.class, fn.getClass().getSimpleName() + Linq.from(caller).toJoinString(Constants.STACK_TRACE_FLAG), id == null ? null : new Object[]{id}, r, ex, System.nanoTime() - s); } return r; diff --git a/rxlib/src/main/java/org/rx/exception/TraceHandler.java b/rxlib/src/main/java/org/rx/exception/TraceHandler.java index 9d827019..650fe18d 100644 --- a/rxlib/src/main/java/org/rx/exception/TraceHandler.java +++ b/rxlib/src/main/java/org/rx/exception/TraceHandler.java @@ -84,7 +84,6 @@ public static class MetricsEntity implements Serializable { Date modifyTime; } - String FIRST_FLAG = "\nat "; public static final TraceHandler INSTANCE = new TraceHandler(); public static Object[] getMessageCandidate(Object... args) { @@ -194,7 +193,7 @@ public void saveExceptionTrace(Thread t, String msg, Throwable e) { void innerSave(String thread, String msg, Throwable e) { RxConfig.TraceConfig conf = RxConfig.INSTANCE.getTrace(); String stackTrace = ExceptionUtils.getStackTrace(e); - int eMsgFlag = stackTrace.indexOf(FIRST_FLAG); + int eMsgFlag = stackTrace.indexOf(Constants.STACK_TRACE_FLAG); String eMsg = stackTrace.substring(0, eMsgFlag); stackTrace = stackTrace.substring(eMsgFlag + 2); msg = msg == null ? eMsg : String.format("%s\n%s", eMsg, msg);