diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/DatasetMappingUtil.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/DatasetMappingUtil.java index aa37ffa832afe1696925be41cee4ad9e7203f9d0..f160106327df91251342fb948b18ab28ec2f5822 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/DatasetMappingUtil.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/DatasetMappingUtil.java @@ -279,7 +279,7 @@ class DatasetMappingUtil unprocessedLines.add(line); } } - IOUtils.writeLines(unprocessedLines, "\n", new FileOutputStream(mappingFile)); + writeLines(mappingFile, unprocessedLines); } catch (IOException ex) { log.mappingFileError(mappingFile, "cannot clean dataset mappings file: " @@ -287,10 +287,21 @@ class DatasetMappingUtil } } + private static void writeLines(File file, List<String> lines) throws IOException, + FileNotFoundException + { + FileOutputStream stream = new FileOutputStream(file); + IOUtils.writeLines(lines, "\n", stream); + IOUtils.closeQuietly(stream); + } + @SuppressWarnings("unchecked") private static List<String> readLines(File mappingFile) throws IOException, FileNotFoundException { - return IOUtils.readLines(new FileInputStream(mappingFile)); + FileInputStream stream = new FileInputStream(mappingFile); + List lines = IOUtils.readLines(stream); + IOUtils.closeQuietly(stream); + return lines; } } diff --git a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java index be493dc8cabd1fd96db58a38236d7a39f58a38f6..188c98427847b48434615c65d240097aa480c59e 100644 --- a/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java +++ b/rtd_yeastx/source/java/ch/systemsx/cisd/yeastx/etl/LogUtils.java @@ -146,7 +146,8 @@ class LogUtils private void sendErrorMessage(IMailClient mailClient, String notificationEmail) { String subject = String.format(ERROR_NOTIFICATION_EMAIL_SUBJECT, loggingDir.getName()); - mailClient.sendMessage(subject, createErrorNotificationContent(), null, null, notificationEmail); + mailClient.sendMessage(subject, createErrorNotificationContent(), null, null, + notificationEmail); } private String createErrorNotificationContent() @@ -182,7 +183,7 @@ class LogUtils private void notifyUserByLogFile(String message) { - OutputStream output; + OutputStream output = null; try { output = new FileOutputStream(getUserLogFile(loggingDir), true); @@ -191,6 +192,9 @@ class LogUtils { adminError("Cannot notify a user because " + ex.getMessage() + "\n The message was: " + message); + } finally + { + IOUtils.closeQuietly(output); } }