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);