[ 
https://issues.apache.org/jira/browse/CAMEL-10747?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15837966#comment-15837966
 ] 

Rui Gu edited comment on CAMEL-10747 at 1/25/17 4:12 PM:
---------------------------------------------------------

I have also had a look at this problem, and here is my finding:

In 2.17.x camel-spring component, The CamelBeanPostProcessor creates and 
extends the DefaultCamelBeanPostProcessor as an anonymous class and it supposed 
to [override the startService 
method|https://github.com/apache/camel/blob/camel-2.17.5/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java#L124]
 and add the service to the current camel context, the addService method would 
inject in the camel context [there and 
then|https://github.com/apache/camel/blob/camel-2.17.5/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java].
 However due to [this 
commit|https://github.com/apache/camel/commit/9600bc4fec55a4ed02f2404dfd33b3584491ec80],
 the startService signature has been changed but failed to refactor the 
CamelBeanPostProcessor to have the same signature, which rendered the code not 
been used. This is then been removed completely by [this 
commit|https://github.com/apache/camel/commit/1233ea02ae4414a07b76d16b709beefbb0b1e448]
 and release in 2.18.x 

If this method was to reinstated and modified to override the startService 
method properly, it would fix this issue.


was (Author: jackygurui):
I have also had a look at this problem, and here is my finding:

In 2.17.x camel-spring component, The CamelBeanPostProcessor extends the 
DefaultCamelBeanPostProcessor and it supposed to [override the startService 
method|https://github.com/apache/camel/blob/camel-2.17.5/components/camel-spring/src/main/java/org/apache/camel/spring/CamelBeanPostProcessor.java#L124]
 and add the service to the current camel context, the addService method would 
inject in the camel context [there and 
then|https://github.com/apache/camel/blob/camel-2.17.5/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java].
 However due to [this 
commit|https://github.com/apache/camel/commit/9600bc4fec55a4ed02f2404dfd33b3584491ec80],
 the startService signature has been changed but failed to refactor the 
CamelBeanPostProcessor to have the same signature, which rendered the code not 
been used. This is then been removed completely by [this 
commit|https://github.com/apache/camel/commit/1233ea02ae4414a07b76d16b709beefbb0b1e448]
 and release in 2.18.x 

If this method was to reinstated and modified to override the startService 
method properly, it would fix this issue.

> CamelContext is not been set in VMConsumer when used with POJO @Consume
> -----------------------------------------------------------------------
>
>                 Key: CAMEL-10747
>                 URL: https://issues.apache.org/jira/browse/CAMEL-10747
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.17.4, 2.17.5, 2.18.1
>         Environment: Ubuntu 16.04, OpenJDK 1.7, OpenJDK 1.8, Spring 
> 4.2.6.RELEASE
>            Reporter: Christopher Harris
>
> In Spring environment, [DefaultCamelBeanPostProcessor relies on 
> CamelPostProcessorHelper to inject 
> consumer|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelBeanPostProcessor.java#L214]
>  , when [CamelPostProcessorHelper creates a 
> VMConsumer|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java#L108]
>  from the endpoint based on the use of @Consume annotation, it then tries to 
> start the consumer as a service. 
> Because the consumer endpoint of @Consume was created using the camel context 
> from CamelPostProcessorHelper, it puts the VMConsumer  service in to 
> [deferred 
> start|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/impl/CamelPostProcessorHelper.java#L123]
>  until the camel context is finished starting. The service is ultimately been 
> [added to the 
> DeferServiceStartupListener|https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java#L1333].
>  Then the DeferServiceStartupListener tries to start the VMConsumer at a 
> later stage. 2.17.3 and 2.18.0 does not suffer this problem.
> The problem is non of the process above has considered the fact that the 
> VMConsumer is an instance of CamelContextAware and injects the correct camel 
> context to it. This then leads to the VMConsumer tries to prepare the 
> exchange with a null pointer reference as its camel context.
> Because the exchange now has null as camel context, a NPE is thrown at 
> https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java#L519
>  when it tries to create the exchange id.
> This problem only happened after issue 
> [CAMEL-10406|https://issues.apache.org/jira/browse/CAMEL-10406] is merged in



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to