Skip to content

Commit

Permalink
fix: 修复配置文件监听器异常信息打印会出现null的问题 (#11425)
Browse files Browse the repository at this point in the history
  • Loading branch information
hczs authored Nov 24, 2023
1 parent bf17472 commit 736327b
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ void checkListenerMd5() {
}
}
}

private static String getTrace(StackTraceElement[] stackTrace, int traceDeep) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("\n");
int deep = 0;
for (StackTraceElement element : stackTrace) {
stringBuilder.append("\tat ").append(element).append("\n");
deep++;
if (traceDeep > 0 && deep > traceDeep) {
stringBuilder.append("\tat ... \n");
break;
}
}
return stringBuilder.toString();
}

private void safeNotifyListener(final String dataId, final String group, final String content, final String type,
final String md5, final String encryptedDataKey, final ManagerListenerWrap listenerWrap) {
Expand Down Expand Up @@ -226,7 +241,7 @@ public void run() {
name, dataId, group, md5, listener, ex.getErrCode(), ex.getErrMsg());
} catch (Throwable t) {
LOGGER.error("[{}] [notify-error] dataId={}, group={}, md5={}, listener={} tx={}", name, dataId,
group, md5, listener, t.getCause());
group, md5, listener, getTrace(t.getStackTrace(), 3));
} finally {
Thread.currentThread().setContextClassLoader(myClassLoader);
}
Expand Down

0 comments on commit 736327b

Please sign in to comment.