fix:ApiErrorLogServiceImpl 在微服务场景下,记录日志存在的循环调用的问题
This commit is contained in:
@@ -40,11 +40,16 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
|
|||||||
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
|
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
|
||||||
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
|
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
|
||||||
apiErrorLog.setRequestParams(StrUtils.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
|
apiErrorLog.setRequestParams(StrUtils.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
|
||||||
if (TenantContextHolder.getTenantId() != null) {
|
try {
|
||||||
apiErrorLogMapper.insert(apiErrorLog);
|
if (TenantContextHolder.getTenantId() != null) {
|
||||||
} else {
|
apiErrorLogMapper.insert(apiErrorLog);
|
||||||
// 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败!
|
} else {
|
||||||
TenantUtils.executeIgnore(() -> apiErrorLogMapper.insert(apiErrorLog));
|
// 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败!
|
||||||
|
TenantUtils.executeIgnore(() -> apiErrorLogMapper.insert(apiErrorLog));
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// 兜底处理,目前只有 yudao-cloud 会发生:https://gitee.com/yudaocode/yudao-cloud-mini/issues/IC1O0A
|
||||||
|
log.error("[createApiErrorLog][记录时({}) 发生异常]", createDTO, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user