gnodet opened a new pull request, #26221:
URL: https://github.com/apache/camel/pull/26221

   Fixes [CAMEL-24651](https://issues.apache.org/jira/browse/CAMEL-24651): 
regression introduced by commit f9048eb0a822 ("consolidate duplicated code for 
printing the stack traces").
   
   ## Problem
   
   When `${exception.stacktrace}` is evaluated on an exchange that has no 
exception:
   
   1. `LanguageHelper.exceptionStacktrace()` calls `exception(exchange)` which 
returns `null`
   2. That `null` is passed to `ExceptionHelper.stackTraceToString(null)`
   3. `stackTraceToString()` calls `e.printStackTrace(printWriter)` → **NPE**
   
   Prior to the refactoring, the call site had an explicit null check that was 
lost during consolidation. `LanguageHelper.exceptionMessage()` still has its 
null guard and is unaffected.
   
   ## Fix
   
   Add a null guard at the top of `ExceptionHelper.stackTraceToString()` so it 
returns `null` when the supplied `Throwable` is `null`. This is the defensive 
approach: it protects all callers rather than just the one in `LanguageHelper`.
   
   ## Test
   
   Added `SimpleTest#testExceptionStacktraceNoException` to cover the 
regression: evaluating `${exception.stacktrace}` on an exchange with no 
exception must return `null` (not throw NPE).


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