xh123637 opened a new pull request, #4481:
URL: https://github.com/apache/logging-log4j2/pull/4481

   `MemoryMappedFileAppender.Builder.build()` passes the configured 
`immediateFlush` value to the `MemoryMappedFileManager` but a hard-coded 
`false` to the appender constructor, so `getImmediateFlush()` always returns 
`false` and the mapped buffer is only forced at end of batch, remap or close. 
This replaces the hard-coded `false` with `isImmediateFlush()`, matching the 
fix for `ConsoleAppender` in #4325.
   
   Fixes #4480.
   
   ## Verification
   
   Added `testImmediateFlushTrue` and `testImmediateFlushFalse` to 
`MemoryMappedFileAppenderTest`, asserting `getImmediateFlush()` for both 
configured values, plus a changelog entry 
(`4480_memory_mapped_file_immediate_flush.xml`).
   
   The full Maven build could not be run in this environment (no access to 
Maven Central), so `./mvnw verify` was not run locally; CI is the arbiter. 
Instead, the changed class was compiled with `javac` (JDK 21) against the 
released `log4j-api`/`log4j-core` 2.26.1 jars and exercised with a standalone 
harness that builds the appender via the builder and reads 
`getImmediateFlush()` for `true`, `false`, and the default:
   
   * Before the fix (HEAD code): `true` -> `false`, `false` -> `false`, default 
-> `false` (bug reproduced).
   * After the fix (patched class first on the classpath): `true` -> `true`, 
`false` -> `false`, default -> `true`.
   
   ## Checklist
   
   * Base your changes on `2.x` branch if you are targeting Log4j 2; use `main` 
otherwise
   * `./mvnw verify` succeeds ([the build 
instructions](https://logging.apache.org/log4j/2.x/development.html#building))
   * Non-trivial changes contain an entry file in the `src/changelog/.2.x.x` 
directory
   * Tests are provided
   


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