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

Willem Jiang commented on CAMEL-12610:
--------------------------------------

I'm sorry the fix break the build(my bad), the issue is caused by the processor 
for bean should not be cached.  
If we set the cached option to false , it should get the new instance from the 
registry.  If we don't want to the POJO bean has nothing to do with the 
Processor converter, we may need to provide other way for use to inject their 
customer processor.

 

> Camel bean component invokes cached instance of bean (that impl processor) in 
> Registry
> --------------------------------------------------------------------------------------
>
>                 Key: CAMEL-12610
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12610
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.20.3, 2.21.1, 2.22.0
>         Environment: N/A
>            Reporter: Jan Bednar
>            Assignee: Willem Jiang
>            Priority: Minor
>             Fix For: 2.21.2, 2.22.1, 2.23.0
>
>         Attachments: Referring objects for originalInstance.png, Stack during 
> second invocation of SomeDependentBean.txt
>
>
> Related SO question: 
> [https://stackoverflow.com/questions/51108913/camel-bean-component-invokes-cached-instance-of-named-dependent-bean]
> Every invocation of bean component should query Registry for actual instance. 
> Now it is cached in {{BeanProcessor#delegate}} variable, even if endpoint 
> parameter {{cache=false}} specified.
> This behavior breaks java-ee compliance: 
> [https://docs.oracle.com/javaee/7/api/javax/enterprise/context/Dependent.html]
> {quote}Every invocation of the [{{Context.get(Contextual, 
> CreationalContext)}}|https://docs.oracle.com/javaee/7/api/javax/enterprise/context/spi/Context.html#get-javax.enterprise.context.spi.Contextual-javax.enterprise.context.spi.CreationalContext-]
>  operation of the context object for the {{@Dependent}} scope returns a new 
> instance of the given bean.
> {quote}
> Marking this as Major, because upgrading of Camel from 2.19.x to 2.2x.x leads 
> to unpredictable results in CDI environment. Since this is tied to CDI 
> environment, this issue is hard to notice even in well junit covered 
> application and can result in major issues in pre-production or production 
> environment.
> Full reproducible project with unit test and deployable WAR package, which 
> passes with 2.19.x and lower. Fails with 2.20.x and higher [on 
> Github|https://github.com/bedlaj/camel-dependent-bean]. 
> Attachments are based on version 2.21.1



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to