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

   ## Summary
   
   The `loadClass` method in `ThrowableExtendedStackTraceRenderer` only catches 
`Exception`,
   but `ClassLoader` can throw `NoClassDefFoundError`, which extends 
`LinkageError` (an `Error`
   subclass). This causes the entire log event to fail with 
`AppenderLoggingException` instead
   of gracefully degrading when a class in the stack trace cannot be resolved.
   
   ## Changes
   
   - **`ThrowableExtendedStackTraceRenderer.java`**: Changed `catch 
(Exception)` to
     `catch (Exception | LinkageError)` in the `loadClass` method
   - **`ThrowableExtendedStackTraceRendererTest.java`**: Added two test cases:
     - Verifies rendering succeeds when a stack trace references a non-existent 
class
     - Verifies rendering succeeds when a custom `ClassLoader` throws 
`NoClassDefFoundError`
   - **Changelog entry**: Added 
`4028_fix_catch_LinkageError_in_ThrowableExtendedStackTraceRenderer.xml`
   
   ## Root Cause
   ```java
   // Before: Only catches Exception — NoClassDefFoundError (Error) escapes
   catch (final Exception ignored)
   
   // After: Also catches LinkageError, which is the parent of 
NoClassDefFoundError
   catch (final Exception | LinkageError ignored)
   ```
   
   Java's `Throwable` hierarchy:
   
   ```
   Throwable
   ├── Exception        ← previously caught
   └── Error
   └── LinkageError ← now also caught
   └── NoClassDefFoundError
   ```
   Fixes #4028


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