fix(task): 校验任务节点执行参数并记录异常日志
- 添加对任务代码参数的非空校验,避免空指针异常 - 在任务节点执行失败时记录详细的错误日志 - 优化异常处理流程,确保错误信息准确传递
This commit is contained in:
@@ -45,6 +45,9 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob {
|
|||||||
private Thread workThread = null;
|
private Thread workThread = null;
|
||||||
|
|
||||||
private String getBeanAlias(String code) {
|
private String getBeanAlias(String code) {
|
||||||
|
if (StrUtil.isBlank(code)) {
|
||||||
|
throw new ServerException("参数code必填");
|
||||||
|
}
|
||||||
// node_init
|
// node_init
|
||||||
String[] s = code.split("_");
|
String[] s = code.split("_");
|
||||||
return Arrays.stream(s).map(StrUtil::upperFirst).collect(Collectors.joining());
|
return Arrays.stream(s).map(StrUtil::upperFirst).collect(Collectors.joining());
|
||||||
@@ -172,6 +175,7 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob {
|
|||||||
executor.execute(codeIdMap.getOrDefault(code, null), dataMap, taskTemplateNodeVo);
|
executor.execute(codeIdMap.getOrDefault(code, null), dataMap, taskTemplateNodeVo);
|
||||||
taskInstanceDetailService.fastSuccessWithInfo(id, code, null);
|
taskInstanceDetailService.fastSuccessWithInfo(id, code, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("任务节点执行失败", e);
|
||||||
taskInstanceDetailService.fastFailWithInfo(id, code, e.getMessage());
|
taskInstanceDetailService.fastFailWithInfo(id, code, e.getMessage());
|
||||||
throw new ServerException(e);
|
throw new ServerException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user