提交 e3cce634 编写于 作者: 许雪里's avatar 许雪里

脚本任务Log文件流关闭优化

上级 179efa6b
......@@ -1208,6 +1208,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 11、任务回调结果优化,支持展示在Rolling log中,方便问题排查;
- 12、脚本任务异常Log输出优化;
- 13、任务线程停止变量修饰符优化;
- 14、脚本任务Log文件流关闭优化;
### TODO LIST
......
......@@ -60,7 +60,10 @@ public class ScriptUtil {
// 标准输出:print (null if watchdog timeout)
// 错误输出:logging + 异常 (still exists if watchdog timeout)
// 标准输入
try (FileOutputStream fileOutputStream = new FileOutputStream(logFile, true)) {
FileOutputStream fileOutputStream = null; //
try {
fileOutputStream = new FileOutputStream(logFile, true);
PumpStreamHandler streamHandler = new PumpStreamHandler(fileOutputStream, fileOutputStream, null);
// command
......@@ -79,6 +82,15 @@ public class ScriptUtil {
} catch (Exception e) {
XxlJobLogger.log(e);
return -1;
} finally {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
XxlJobLogger.log(e);
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册