From 20559ff540bbbb5873ac330bfb726bac3cd90f7e Mon Sep 17 00:00:00 2001 From: Fate-JH Date: Tue, 19 Dec 2023 13:15:59 -0500 Subject: [PATCH] tightening of the noose --- .../psforever/tools/decodePackets/DecodePackets.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala b/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala index f7c8d0d32..a3723a3e0 100644 --- a/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala +++ b/tools/decode-packets/src/main/scala/net/psforever/tools/decodePackets/DecodePackets.scala @@ -29,7 +29,7 @@ object DecodePackets { /** important: must be Java's System.out! */ private val normalSystemOut = System.out /** important: must be composed of Java classes; log4j interacts with the system as a Java library */ - private val outCapture: PrintStream = new PrintStream(new DeafMuteStream()) + private var outCapture: PrintStream = _ def main(args: Array[String]): Unit = { val builder = OParser.builder[Config] @@ -120,11 +120,16 @@ object DecodePackets { normalWriter } + //create a decoy console output stream (suppress output from the decode process) + outCapture = new PrintStream(new DeafMuteStream()) if (opts.preprocessed) { decodeFilesUsing(files, extension = ".txt", tmpFolder, opts.outDir, bufferedWriter, preprocessed) } else { decodeFilesUsing(files, extension = ".gcap", tmpFolder, opts.outDir, bufferedWriter, gcapy) } + //close and null the decoy console output stream + outCapture.close() + outCapture = null if (deleteTempFolderAfterwards) { //if the temporary directory only exists because of this script, it should be safe to delete it @@ -137,8 +142,6 @@ object DecodePackets { ) deleteThese.foreach(FileUtils.forceDelete) } - //close the decoy console output stream that's been running since the application started - outCapture.close() } /**