You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/01/15 08:50:42 UTC

[camel-spring-boot] branch camel-spring-boot-3.14.x updated: CAMEL-17492: camel-core - Camel bean post processor should have injected camel context to avoid NPE such as when using spring boot and doing camel endpoint injected dependency injection.

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

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


The following commit(s) were added to refs/heads/camel-spring-boot-3.14.x by this push:
     new 85a40e2  CAMEL-17492: camel-core - Camel bean post processor should have injected camel context to avoid NPE such as when using spring boot and doing camel endpoint injected dependency injection.
85a40e2 is described below

commit 85a40e29a8a617dccf79d0aa043435ac5c317d4a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 15 09:39:47 2022 +0100

    CAMEL-17492: camel-core - Camel bean post processor should have injected camel context to avoid NPE such as when using spring boot and doing camel endpoint injected dependency injection.
---
 .../java/org/apache/camel/spring/boot/CamelAutoConfiguration.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index 625a221..eb22b16 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -74,8 +74,12 @@ public class CamelAutoConfiguration {
     @Bean(destroyMethod = "")
     @ConditionalOnMissingBean(CamelContext.class)
     CamelContext camelContext(ApplicationContext applicationContext,
-                              CamelConfigurationProperties config) throws Exception {
+                              CamelConfigurationProperties config,
+                              CamelBeanPostProcessor beanPostProcessor) throws Exception {
         CamelContext camelContext = new SpringBootCamelContext(applicationContext, config.isWarnOnEarlyShutdown());
+        // bean post processor is created before CamelContext
+        beanPostProcessor.setCamelContext(camelContext);
+        camelContext.adapt(ExtendedCamelContext.class).setBeanPostProcessor(beanPostProcessor);
         return doConfigureCamelContext(applicationContext, camelContext, config);
     }