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

Jan Bednar commented on CAMEL-12610:
------------------------------------

Understand [~davsclaus]. Thanks. Our application relies on that. We have 
implemented thousands of plugins, which are called dynamically with 
dynamicRouter based on rules defined in database. Every plugin implements 
Processor interface. Because of the dynamicRouter it is not so easy replace 
bean component with .process EIP. I was thinking about replacing 
.to("bean:something") with .to("something"), as described in Processor 
documentation, but it invokes the same instance too.

> 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