From 586260b9f877e0954513fcffb0aa27eaddc5d0ff Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 10 May 2022 12:26:35 +0100 Subject: [PATCH] JWS-128 patch out log4j references in the compbio.FileUtil class, and corresponding calls to methods in the JABAWS client and engine code. --- compbio-utils/compbio/util/FileUtil.java | 34 +++++++------------- engine/compbio/engine/client/ConfExecutable.java | 2 +- engine/compbio/engine/client/EngineUtil.java | 4 +-- engine/compbio/engine/client/Util.java | 4 +-- engine/compbio/engine/local/ExecutableWrapper.java | 4 +-- 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/compbio-utils/compbio/util/FileUtil.java b/compbio-utils/compbio/util/FileUtil.java index 7456a05..dc10637 100644 --- a/compbio-utils/compbio/util/FileUtil.java +++ b/compbio-utils/compbio/util/FileUtil.java @@ -204,7 +204,7 @@ public class FileUtil { try { out.close(); } finally { - closeSilently(log, out); + closeSilently(out); } return file; } @@ -228,9 +228,9 @@ public class FileUtil { bis.close(); inStream.close(); } finally { - closeSilently(log, out); - closeSilently(log, bis); - closeSilently(log, inStream); + closeSilently(out); + closeSilently(bis); + closeSilently(inStream); } return result; } @@ -245,7 +245,7 @@ public class FileUtil { try { contentStr.close(); } finally { - closeSilently(log, contentStr); + closeSilently(contentStr); } return content; } @@ -287,8 +287,8 @@ public class FileUtil { br.close(); reader.close(); } finally { - closeSilently(log, br); - closeSilently(log, reader); + closeSilently(br); + closeSilently(reader); } } return fileStr; @@ -313,8 +313,8 @@ public class FileUtil { bw.close(); fwriter.close(); } finally { - closeSilently(log, bw); - closeSilently(log, fwriter); + closeSilently(bw); + closeSilently(fwriter); } } @@ -337,8 +337,8 @@ public class FileUtil { bw.close(); outStream.close(); } finally { - closeSilently(log, bw); - closeSilently(log, outStream); + closeSilently(bw); + closeSilently(outStream); } } @@ -366,23 +366,13 @@ public class FileUtil { return Arrays.asList(new File(path).list(filter)); } - public final static void closeSilently(Logger log, Closeable stream) { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - log.warning(e.getLocalizedMessage() + " Cause \n"+e.getCause()); - } - } - } - public final static void closeSilently(Closeable stream) { if (stream != null) { try { stream.close(); } catch (IOException e) { - log.warning(e.getLocalizedMessage()+" Cause \n"+e.getCause()); + System.err.println(e.getLocalizedMessage()+" Cause \n"+e.getCause()); } } } diff --git a/engine/compbio/engine/client/ConfExecutable.java b/engine/compbio/engine/client/ConfExecutable.java index dcce7d2..bd24840 100644 --- a/engine/compbio/engine/client/ConfExecutable.java +++ b/engine/compbio/engine/client/ConfExecutable.java @@ -276,7 +276,7 @@ public class ConfExecutable implements ConfiguredExecutable { } catch (JAXBException e) { log.warning(e.getLocalizedMessage()+" Caused by\n"+e.getCause()); } finally { - FileUtil.closeSilently(log, confFileStream); + FileUtil.closeSilently(confFileStream); } return rconf; } diff --git a/engine/compbio/engine/client/EngineUtil.java b/engine/compbio/engine/client/EngineUtil.java index d5c30af..906745f 100644 --- a/engine/compbio/engine/client/EngineUtil.java +++ b/engine/compbio/engine/client/EngineUtil.java @@ -99,7 +99,7 @@ public final class EngineUtil { + workDirectory + " for local execution! Ignoring... " + e.getMessage()); } finally { - FileUtil.closeSilently(log, writer); + FileUtil.closeSilently(writer); } } @@ -376,7 +376,7 @@ public final class EngineUtil { "Could not load run configuration!" + e.getMessage()+"\n"+ e.getCause()); } finally { - FileUtil.closeSilently(log, fileInStream); + FileUtil.closeSilently(fileInStream); } return exec; } diff --git a/engine/compbio/engine/client/Util.java b/engine/compbio/engine/client/Util.java index c57596c..f558153 100644 --- a/engine/compbio/engine/client/Util.java +++ b/engine/compbio/engine/client/Util.java @@ -99,7 +99,7 @@ public final class Util { + workDirectory + " for local execution! Ignoring... " + e.getMessage()); } finally { - FileUtil.closeSilently(log, writer); + FileUtil.closeSilently(writer); } } @@ -376,7 +376,7 @@ public final class Util { "Could not load run configuration!" + e.getMessage(), e.getCause()); } finally { - FileUtil.closeSilently(log, fileInStream); + FileUtil.closeSilently(fileInStream); } return exec; } diff --git a/engine/compbio/engine/local/ExecutableWrapper.java b/engine/compbio/engine/local/ExecutableWrapper.java index 1cdf9a4..dbf12ae 100644 --- a/engine/compbio/engine/local/ExecutableWrapper.java +++ b/engine/compbio/engine/local/ExecutableWrapper.java @@ -209,8 +209,8 @@ public final class ExecutableWrapper implements } // hack - we probably lost log messages here. java.util.logging.Logger logger = java.util.logging.Logger.getLogger(this.getClass().getCanonicalName()); - FileUtil.closeSilently(logger, errorStream); - FileUtil.closeSilently(logger, outStream); + FileUtil.closeSilently(errorStream); + FileUtil.closeSilently(outStream); } return confExec; } -- 1.7.10.2