abhinav-phi commented on code in PR #4341:
URL: https://github.com/apache/logging-log4j2/pull/4341#discussion_r4190021569


##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderTest.java:
##########
@@ -154,6 +156,51 @@ void testDefaultAppenderImmediateFlush() {
         }
     }
 
+    @Test
+    void testBufferSizeHonored() {
+        final ConsoleAppender app = ConsoleAppender.newBuilder()
+                .setName("testBufferSizeHonored")
+                .setBufferSize(16384)
+                .build();
+        try {
+            assertNotNull(app.getManager());
+            assertEquals(16384, app.getManager().getByteBuffer().capacity());
+        } finally {
+            app.stop();
+        }
+    }
+
+    @Test
+    void testDefaultBufferSize() {
+        final ConsoleAppender app =
+                
ConsoleAppender.newBuilder().setName("testDefaultBufferSize").build();
+        try {
+            assertEquals(Constants.ENCODER_BYTE_BUFFER_SIZE, 
app.getManager().getByteBuffer().capacity());
+        } finally {
+            app.stop();
+        }
+    }

Review Comment:
   done in 26694b9, testUnbufferedIoForcesImmediateFlush is in the test class 
and it does fail if the !bufferedIo term is dropped, i traced it through 
AbstractOutputStreamAppender, the stored flag is returned verbatim so the 
assertion is not a tautology



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java:
##########
@@ -236,16 +237,22 @@ public ConsoleAppender build() {
                     ? getDirectOutputStream(target)
                     : follow ? getFollowOutputStream(target) : 
getDefaultOutputStream(target);
 
-            final String managerName = target.name() + '.' + follow + '.' + 
direct;
-            final OutputStreamManager manager =
-                    OutputStreamManager.getManager(managerName, new 
FactoryData(stream, managerName, layout), factory);
+            final boolean bufferedIo = isBufferedIo();
+            final int bufferSize = getBufferSize();
+            if (!bufferedIo && bufferSize > 0) {
+                LOGGER.warn("The bufferSize is set to {} but bufferedIo is 
false.", bufferSize);
+            }

Review Comment:
   dropped in 26694b9, the warning is gone, LOGGER is still used by the charset 
and direct/follow warnings so the import stays



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java:
##########
@@ -236,16 +237,22 @@ public ConsoleAppender build() {
                     ? getDirectOutputStream(target)
                     : follow ? getFollowOutputStream(target) : 
getDefaultOutputStream(target);
 
-            final String managerName = target.name() + '.' + follow + '.' + 
direct;
-            final OutputStreamManager manager =
-                    OutputStreamManager.getManager(managerName, new 
FactoryData(stream, managerName, layout), factory);
+            final boolean bufferedIo = isBufferedIo();
+            final int bufferSize = getBufferSize();
+            if (!bufferedIo && bufferSize > 0) {
+                LOGGER.warn("The bufferSize is set to {} but bufferedIo is 
false.", bufferSize);
+            }
+            final String managerName =
+                    target.name() + '.' + follow + '.' + direct + '.' + 
bufferedIo + '.' + bufferSize;

Review Comment:
   done in 26694b9, managerName is target.name() + '.' + follow + '.' + direct 
+ '.' + bufferSize, bufferedIo is out of the key so identical managers are not 
split anymore



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to