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

   Fixes #4334.
   
   `%rEx{short.className}` (and `short.methodName` / `short.lineNumber` / 
`short.fileName`) indexed `getStackTrace()[0]` on the root cause without 
checking length. An empty stack trace is legal (`setStackTrace(new 
StackTraceElement[0])`, `writableStackTrace = false`, HotSpot 
`-XX:+OmitStackTraceInFastThrow`) and threw `ArrayIndexOutOfBoundsException`. 
`%ex{short.*}` already guards this path.
   
   This change mirrors `ThrowablePropertyRendererFactory`'s empty-stack guard 
in `ThrowableInvertedPropertyRendererFactory.extractThrowingMethod`.
   
   ## Test
   
   Executed:
   
   ```
   JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 ./mvnw -pl log4j-core-test -am 
test 
-Dtest=RootThrowablePatternConverterTest#short_properties_should_not_fail_when_root_cause_has_empty_stack_trace
 -Dsurefire.failIfNoSpecifiedTests=false
   ```
   
   RED: 4 errors (`ArrayIndexOutOfBoundsException` at `extractThrowingMethod`). 
GREEN: 4 tests, 0 failures.
   
   Also executed `RootThrowablePatternConverterTest$PropertyTest` and 
`ThrowablePatternConverterTest$PropertyTest`: 256 tests, 0 failures.
   
   ## Checklist
   
   * Base your changes on `2.x` branch if you are targeting Log4j 2; use `main` 
otherwise
   * Focused tests passed as above
   * Changelog entry in `src/changelog/.2.x.x`
   * 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