You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "mayur mohan (Jira)" <ji...@apache.org> on 2026/08/19 15:54:00 UTC
[jira] [Created] (CAMEL-24404) camel-base-engine: InternalRouteStartupManager re-throws consumer startup exceptions raw instead of wrapping in FailedToStartRouteException
mayur mohan created CAMEL-24404:
-----------------------------------
Summary: camel-base-engine: InternalRouteStartupManager re-throws consumer startup exceptions raw instead of wrapping in FailedToStartRouteException
Key: CAMEL-24404
URL: https://issues.apache.org/jira/browse/CAMEL-24404
Project: Camel
Issue Type: Bug
Components: camel-base-engine
Reporter: mayur mohan
h2. Problem
In {code}InternalRouteStartupManager.doStartOrResumeRouteConsumers(){code}, two catch blocks re-throw the consumer startup exception raw with a bare {code}throw e{code}. When a consumer start() throws a message-less exception such as a bare NullPointerException (e.g. from FileConsumer.doStart()), the NPE escapes directly to callers instead of being wrapped in a proper FailedToStartRouteException.
h2. Stack Trace
{noformat}
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.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:214)
at org.apache.camel.impl.engine.DefaultRouteController.doStartOrResumeRoutes(DefaultRouteController.java:272)
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.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2789)
at org.apache.camel.support.service.BaseService.start(BaseService.java:119)
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2460)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:198)
{noformat}
h2. Root Cause
Both catch blocks in doStartOrResumeRouteConsumers() use bare {code}throw e{code}. If the exception carries a null message (e.g. new NullPointerException()), wrapping it later in FailedToStartRouteException would fail with a secondary NPE from Objects.requireNonNull inside the constructor.
Note: RouteService.warmUp() and RouteService.setUp() have the same null-message problem and are fixed separately in PR https://github.com/apache/camel/pull/25205.
h2. Fix
Replace both bare {code}throw e{code} sites with FailedToStartRouteException wrapping using an extractUsefulMessage() helper that walks the cause chain for a non-null message.
h2. Files Changed
* {code}core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/InternalRouteStartupManager.java{code}
** Both throw e sites replaced with FailedToStartRouteException wrapping
** Added extractUsefulMessage() private static helper
* {code}core/camel-core/src/test/java/org/apache/camel/impl/engine/InternalRouteStartupManagerConsumerStartTest.java{code} (new)
** testConsumerStartNullMessageProducesFailedToStartRouteException
** testConsumerStartWalksCauseChainForMessage
h2. Test Results
{noformat}
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 [JDK 21 / Maven 3.9]
BUILD SUCCESS
{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)