From 91961ad72a1416185abe260c4d56a0762a452223 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Sat, 21 Sep 2024 20:43:54 +0200 Subject: [PATCH] add comments to OutputStreamAppender Signed-off-by: Ceki Gulcu --- .../main/java/ch/qos/logback/core/OutputStreamAppender.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java b/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java index 1029dfd980..b7a02feedf 100755 --- a/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java +++ b/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java @@ -136,7 +136,7 @@ public void stop() { protected void closeOutputStream() { if (this.outputStream != null) { try { - // before closing we have to output out layout's footer + // before closing we have to output out encooder's footer encoderClose(); this.outputStream.close(); this.outputStream = null; @@ -204,6 +204,8 @@ private void writeBytes(byte[] byteArray) throws IOException { streamWriteLock.lock(); try { + // guard against appender having been stop() in parallel + // note that the encoding step is performed outside the protection of the streamWriteLock if(isStarted()) { writeByteArrayToOutputStreamWithPossibleFlush(byteArray); updateByteCount(byteArray);