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

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


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

commit e6e929b5d42941f21ee6b0b678d4d44676a05a1d
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 91550c0ecf3..571c6985d1b 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