This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.8.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.8.x by this push:
     new b47b8099b78 CAMEL-20628: When adding route policy factory / lifecycle 
strategy then inject camel context if aware to avoid NPEs
b47b8099b78 is described below

commit b47b8099b7862d9f4b4dc2f8c15c9d773c0664b0
Author: Claus Ibsen <claus.ib...@gmail.com>
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 e12bd58a0b0..26c81832872 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
@@ -1712,6 +1712,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);
@@ -1745,6 +1747,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);

Reply via email to