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

   Fixes #4243
   
   ## Description
   
   `CsvParameterLayout.toSerializable` passes `Message.getParameters()` to 
`CSVFormat.printRecord` without a null check. Parameter-less messages such as 
`SimpleMessage` return `null` from `getParameters()`, and Commons CSV throws 
`NullPointerException` when the values array is null. Only `IOException` is 
caught, so the NPE escapes to the appender and the event is lost.
   
   This change treats a null parameter array as `Constants.EMPTY_OBJECT_ARRAY`, 
which produces a well-formed empty CSV record (record separator only) and 
matches the zero-length parameters case.
   
   ## 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
   
   ## Testing
   
   - JDK 17 (branch enforcer requires `[17,18)`)
   - `./mvnw test -pl :log4j-core-test -am 
-Dtest=CsvParameterLayoutTest#testNullParametersProduceEmptyRecord 
-Dsurefire.failIfNoSpecifiedTests=false` — **2/2 pass**
   - Related existing layout tests in the same class 
(`testLayoutDefaultNormal`, `testLayoutDefaultObjectArrayMessage`, 
`testLayoutTab`, charset/content-type tests) also pass
   - Spotless check clean on `:log4j-core` and `:log4j-core-test`


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