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:48:46 UTC

[camel-spring-boot] branch main 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 main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 80c662b  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.
80c662b is described below

commit 80c662bdc7134cd67561aef8600d84a74b7b2b90
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);
     }