This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push:
new bc9cad96518 CAMEL-20628: When adding route policy factory / lifecycle
strategy then inject camel context if aware to avoid NPEs
bc9cad96518 is described below
commit bc9cad96518b8044c798479bc022d7bc83db49af
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 3 13:52:45 2024 +0200
CAMEL-20628: When adding route policy factory / lifecycle strategy then
inject camel context if aware to avoid NPEs
---
.../main/java/org/apache/camel/impl/engine/AbstractCamelContext.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 062b07914bf..af5732fd8f5 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -1662,6 +1662,8 @@ public abstract class AbstractCamelContext extends
BaseService
@Override
public void addLifecycleStrategy(LifecycleStrategy lifecycleStrategy) {
+ // ensure camel context is injected in factory
+ CamelContextAware.trySetCamelContext(lifecycleStrategy, this);
// avoid adding double which can happen with spring xml on spring boot
if (!getLifecycleStrategies().contains(lifecycleStrategy)) {
getLifecycleStrategies().add(lifecycleStrategy);
@@ -1695,6 +1697,8 @@ public abstract class AbstractCamelContext extends
BaseService
@Override
public void addRoutePolicyFactory(RoutePolicyFactory routePolicyFactory) {
+ // ensure camel context is injected in factory
+ CamelContextAware.trySetCamelContext(routePolicyFactory, this);
// avoid adding double which can happen with spring xml on spring boot
if (!getRoutePolicyFactories().contains(routePolicyFactory)) {
getRoutePolicyFactories().add(routePolicyFactory);