You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2021/02/25 23:44:40 UTC

[GitHub] [logging-log4j2] carterkozak commented on a change in pull request #470: [LOG4J2-3028] OutputStreamManager#flushBuffer always clears the buffer.

carterkozak commented on a change in pull request #470:
URL: https://github.com/apache/logging-log4j2/pull/470#discussion_r583283312



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java
##########
@@ -278,10 +278,13 @@ protected synchronized void flushDestination() {
      */
     protected synchronized void flushBuffer(final ByteBuffer buf) {
         ((Buffer) buf).flip();

Review comment:
       So previously in the exceptional case, we would fail out before calling clear, leaving ourselves with buffer position zero, limit N (potentially a small fraction of the capacity, based on potentially a single event).
   Subsequent attempts to flush the buffer can only further reduce the available buffer space until our limit and position converge. At that point our `buf.remaining() > 0` condition can never succeed if I'm reasoning through this correctly, and we cannot write any data.
   Great catch!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org