提交 cf1768d2 authored 作者: xuxueli's avatar xuxueli

Merge branch 'master' of https://github.com/xuxueli/xxl-job

...@@ -1212,6 +1212,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 ...@@ -1212,6 +1212,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 11、任务回调结果优化,支持展示在Rolling log中,方便问题排查; - 11、任务回调结果优化,支持展示在Rolling log中,方便问题排查;
- 12、脚本任务异常Log输出优化; - 12、脚本任务异常Log输出优化;
- 13、任务线程停止变量修饰符优化; - 13、任务线程停止变量修饰符优化;
- 14、脚本任务Log文件流关闭优化;
### TODO LIST ### TODO LIST
......
...@@ -115,12 +115,13 @@ public class XxlJobFileAppender { ...@@ -115,12 +115,13 @@ public class XxlJobFileAppender {
appendLog += "\r\n"; appendLog += "\r\n";
// append file content // append file content
try {
FileOutputStream fos = null; FileOutputStream fos = null;
try { try {
fos = new FileOutputStream(logFile, true); fos = new FileOutputStream(logFile, true);
fos.write(appendLog.getBytes("utf-8")); fos.write(appendLog.getBytes("utf-8"));
fos.flush(); fos.flush();
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally { } finally {
if (fos != null) { if (fos != null) {
try { try {
...@@ -130,9 +131,6 @@ public class XxlJobFileAppender { ...@@ -130,9 +131,6 @@ public class XxlJobFileAppender {
} }
} }
} }
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
} }
......
...@@ -60,7 +60,10 @@ public class ScriptUtil { ...@@ -60,7 +60,10 @@ public class ScriptUtil {
// 标准输出:print (null if watchdog timeout) // 标准输出:print (null if watchdog timeout)
// 错误输出:logging + 异常 (still exists 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); PumpStreamHandler streamHandler = new PumpStreamHandler(fileOutputStream, fileOutputStream, null);
// command // command
...@@ -79,6 +82,15 @@ public class ScriptUtil { ...@@ -79,6 +82,15 @@ public class ScriptUtil {
} catch (Exception e) { } catch (Exception e) {
XxlJobLogger.log(e); XxlJobLogger.log(e);
return -1; return -1;
} finally {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
XxlJobLogger.log(e);
}
}
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论