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

   ## Summary
   
   Fixes the two bare `throw e` sites in 
`InternalRouteStartupManager.doStartOrResumeRouteConsumers()` that re-threw 
consumer startup exceptions raw instead of wrapping them in 
`FailedToStartRouteException`.
   
   ## JIRA
   
   *(JIRA key will be added as a comment once created)*
   
   ## Root Cause
   
   When a consumer`s `start()` throws a message-less exception (e.g. a bare 
`NullPointerException` from `FileConsumer.doStart()`), the two catch blocks at 
lines 427-432 and 465-470 re-threw it raw with `throw e`. Callers received an 
unwrapped NPE instead of a `FailedToStartRouteException`.
   
   Real-world stack trace:
   ```
   java.lang.NullPointerException
       at 
org.apache.camel.component.file.FileConsumer.doStart(FileConsumer.java:123)
       at 
org.apache.camel.support.service.BaseService.start(BaseService.java:119)
       at 
org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113)
       at 
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRouteConsumers(InternalRouteStartupManager.java:429)
       at 
org.apache.camel.impl.engine.InternalRouteStartupManager.doStartRouteConsumers(InternalRouteStartupManager.java:378)
       at 
org.apache.camel.impl.engine.DefaultRouteController.startRoute(DefaultRouteController.java:147)
       at 
org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:3124)
       at 
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:198)
   ```
   
   Note: `RouteService.warmUp()` and `RouteService.setUp()` have the same 
null-message problem and are fixed separately in PR #25205.
   
   ## Fix
   
   Replace both `throw e` sites with:
   ```java
   throw new FailedToStartRouteException(
           routeService.getId(), routeService.getLocation(),
           extractUsefulMessage(e), e);
   ```
   
   Add `extractUsefulMessage()` helper (same pattern as PR #25205) that walks 
the cause chain for a non-null message and falls back to the simple class name.
   
   ## Changes
   
   - 
`core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/InternalRouteStartupManager.java`
 — replace both `throw e` sites; add `extractUsefulMessage()` helper
   - 
`core/camel-core/src/test/java/org/apache/camel/impl/engine/InternalRouteStartupManagerConsumerStartTest.java`
 (new) — 2 tests
   
   ## Test Results
   
   ```
   Tests run: 2, Failures: 0, Errors: 0, Skipped: 0  [JDK 21 / Maven 3.9]
   BUILD SUCCESS
   ```
   
   ## AI Attribution
   
   This contribution was developed with AI assistance using [Claude 
Code](https://github.com/anthropics/claude-code).
   
   ```
   Co-authored-by: Claude <[email protected]>
   ```
   


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