Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Aug 5, 2024
1 parent 19df3eb commit 4ebab8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions rxlib/src/main/java/org/rx/core/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
6 changes: 3 additions & 3 deletions rxlib/src/main/java/org/rx/core/ThreadPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static <T> Task<T> as(Object fn) {
final Object id;
final InternalThreadLocalMap parent;
final String traceId;
final Class<?> caller;
final Class<?>[] caller;

private Task(Func<T> fn, FlagsEnum<RunFlag> flags, Object id) {
if (flags == null) {
Expand All @@ -179,7 +179,7 @@ private Task(Func<T> fn, FlagsEnum<RunFlag> 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;
}
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions rxlib/src/main/java/org/rx/exception/TraceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4ebab8f

Please sign in to comment.