From df613f163c822f1a6dc6a1a5339d2aae2d7697b5 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Sat, 26 May 2018 13:41:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0RM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xxl/job/core/log/XxlJobFileAppender.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java b/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java index 0c880968..ff89001a 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobFileAppender.java @@ -115,23 +115,21 @@ public class XxlJobFileAppender { appendLog += "\r\n"; // append file content + FileOutputStream fos = null; try { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(logFile, true); - fos.write(appendLog.getBytes("utf-8")); - fos.flush(); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - } - } + fos = new FileOutputStream(logFile, true); + fos.write(appendLog.getBytes("utf-8")); + fos.flush(); } catch (Exception e) { logger.error(e.getMessage(), e); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } } }