[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2020-02-25 Thread Claus Ibsen (Jira)


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

Claus Ibsen commented on CAMEL-12638:
-

Try with latest 2.25.x release. Or 3.x if possible

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Assignee: Claus Ibsen
>Priority: Major
> Fix For: 2.21.3, 2.22.1, 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2020-02-25 Thread Steffen Eitelmann (Jira)


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

Steffen Eitelmann commented on CAMEL-12638:
---

We are using Camel 2.24.2 and the FluentProducerTemplate is definitely still 
not thread-safe. Should I create a new bug ticket?

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Assignee: Claus Ibsen
>Priority: Major
> Fix For: 2.21.3, 2.22.1, 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-08-08 Thread Lukasz (JIRA)


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

Lukasz commented on CAMEL-12638:


The fix looks good to me, thank you!

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Assignee: Claus Ibsen
>Priority: Major
> Fix For: 2.21.3, 2.22.1, 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-08-08 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CAMEL-12638:


davsclaus closed pull request #2459:  CAMEL-12638: FluentProducerTemplate 
should be thread-safe
URL: https://github.com/apache/camel/pull/2459
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Fix For: 2.21.3, 2.22.1, 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-08-08 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CAMEL-12638:


Github user davsclaus closed the pull request at:

https://github.com/apache/camel/pull/2459


> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Fix For: 2.21.3, 2.22.1, 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-08-08 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CAMEL-12638:


GitHub user davsclaus opened a pull request:

https://github.com/apache/camel/pull/2459

 CAMEL-12638: FluentProducerTemplate should be thread-safe



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/apache/camel camel-12638

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/camel/pull/2459.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2459


commit afedbc78afde861075ec218e50eaff12e2b9c7fc
Author: Claus Ibsen 
Date:   2018-08-08T07:57:57Z

CAMEL-12638: FluentProducerTemplate should be thread-safe.

commit efc0e955139565f49f3f6ffd357ba78fa288efcc
Author: Claus Ibsen 
Date:   2018-08-08T07:59:46Z

CAMEL-12638: FluentProducerTemplate should be thread-safe.




> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Fix For: 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-08-08 Thread Claus Ibsen (JIRA)


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

Claus Ibsen commented on CAMEL-12638:
-

I created a PR with a potential fix
https://github.com/apache/camel/pull/2459

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Fix For: 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-08-08 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CAMEL-12638:


davsclaus opened a new pull request #2459:  CAMEL-12638: FluentProducerTemplate 
should be thread-safe
URL: https://github.com/apache/camel/pull/2459
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Fix For: 2.23.0
>
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-27 Thread Willem Jiang (JIRA)


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

Willem Jiang commented on CAMEL-12638:
--

If we set the property to be thread local, we can make it thread-safe, but it 
may introduce some memory leak if we don't use it rightly.


> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-24 Thread Lukasz (JIRA)


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

Lukasz commented on CAMEL-12638:


{quote}So I just add a comment that we need treat FluentProducerTemplate as a 
Builder.
{quote}
[~njiang] I kind of feel like this is not enough... If we want to avoid further 
confusion and potential production issues (our case) I think the class should 
be either made thread-safe for all operations *or* **it should not be possible 
to use it as a _ProducerTemplate_ (and don't create a singleton of this class 
as part of spring-boot-starter).

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-13 Thread Mario Papandrea (JIRA)


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

Mario Papandrea commented on CAMEL-12638:
-

Ah yes sure, sorry! I was hoping exists some scope crating a new instance for 
each call, but is not like this. Anyway my suggestion to remove from the 
camel-spring-boot-starter confoguration is still valid. It shouldn't be used 
that way. 

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-13 Thread Neil Drummond (JIRA)


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

Neil Drummond commented on CAMEL-12638:
---

[~mario.papandrea] I don't think that will fix the issue.

Consider the case of a service that injects {{FluentProducerTemplate}}:
{code:java}
@Service
public class MyService {

@Inject
private FluentProducerTemplate fluentProducerTemplate

public void useProducerTemplate() {

}
}{code}
In this case, if {{useProducerTemplate()}} is called from multiple threads, and 
it uses the {{fluentProducerTemplate}}, then even if you give it prototype 
scope, some instances may still be used in a multithreaded way, and may still 
run into this issue.  (It might make this happen less often, and fix it in some 
cases, but not in all cases).

I think any proper solution that doesn't break the API of 
{{FluentProducerTemplate}} will need {{DefaultFluentProducerTemplate}} to be a 
proper thread-safe class, such that a single instance can be used in multiple 
threads at the same time.

Right now, because {{DefaultFluentProducerTemplate}} implements 
{{FluentProducerTemplate}}, it really ought to be thread-safe, as is guaranteed 
in the javadocs of the {{FluentProducerTemplate}} interface.

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-13 Thread Mario Papandrea (JIRA)


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

Mario Papandrea commented on CAMEL-12638:
-

i suggest also to remove the singleton from spring-boot-starter cause is 
misleading. 

Or maybe  the scope of the bean can be changed to be RequestScope.

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-13 Thread Willem Jiang (JIRA)


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

Willem Jiang commented on CAMEL-12638:
--

OK, I saw the java doc. Normally the template send, request method are thread 
safe, but withBody() is not thread safe, we can fix it by declare the body as 
thread local , but there are some other settings such as endpoint, 
processorSupplier which are not thread safe. So I just add a comment that we 
need treat FluentProducerTemplate as a Builder.

{code:java}
public class DefaultFluentProducerTemplate extends ServiceSupport implements 
FluentProducerTemplate {
private final CamelContext context;
private final ClassValue resultProcessors;
private Map headers;
private Object body;
private Optional> templateCustomizer;
private Optional> exchangeSupplier;
private Optional> processorSupplier;
private Optional endpoint;
private Optional defaultEndpoint;
private int maximumCacheSize;
private boolean eventNotifierEnabled;
private volatile ProducerTemplate template;

...{code}

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-58-09-225.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-12 Thread Mario Papandrea (JIRA)


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

Mario Papandrea commented on CAMEL-12638:
-

Moreover the api doc clearly state  that this object is "thread safe" 

[http://static.javadoc.io/org.apache.camel/camel-core/2.19.3/org/apache/camel/FluentProducerTemplate.html]
 

 

!image-2018-07-12-17-57-11-867.png!

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
> Attachments: image-2018-07-12-17-56-23-086.png, 
> image-2018-07-12-17-57-11-867.png
>
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-12 Thread Lukasz (JIRA)


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

Lukasz commented on CAMEL-12638:


I'm not really convinced by that [~njiang]. Even in the _Camel in Action 
(Second Edition)_ **book, Claus and Jonathan use it a standard bean that can be 
called to execute a service not a builder (see _Listing 7.12 JAX-RS_
_REST implementation_)_:_

 

_@ApplicationScoped
@Path("/api")
public class RulesController \{
   @Inject
   @Uri ( "direct:inventory" )
   private FluentProducerTemplate producer;

   @GET
   @Produces ( MediaType.APPLICATION_JSON )
   @Path ( "/rules/{cartIds}" )
   public List rules( @PathParam ( "cartIds" ) String cartIds ) \{
  List answer = new ArrayList<>();
  ItemsDto inventory = producer.request( ItemsDto.class );
  [...]
   }
}_

 

Obviously they don't refer to a specific implementation but we can all imagine 
which implementation is provided by default. Also if it was supposed to be 
*just* a builder I find it misleading that the class actually implements a 
_Service_ interface.

 

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-12 Thread Willem Jiang (JIRA)


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

Willem Jiang commented on CAMEL-12638:
--

The FluentProducerTemplate works as the Builder class with the fluent API to 
setup the internal states which  is not thread safe. You may need to use the 
DefaultProducerTemplate to do the job.

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-12 Thread Lukasz (JIRA)


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

Lukasz commented on CAMEL-12638:


I came up with the same conclusion as you [~neildrummonddorado]. There is no 
mention about this in the _DefaultFluentProducerTemplate_ javadoc, but the one 
for _FluentProducerTemplate_ clearly states that the producer is threadsafe and 
I would kind of expect that the same should apply for its implementations.

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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


[jira] [Commented] (CAMEL-12638) DefaultFluentProducerTemplate is not thread safe

2018-07-11 Thread Neil Drummond (JIRA)


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

Neil Drummond commented on CAMEL-12638:
---

We just ran into this on a project I am currently working on.

Looking at the {{DefaultFluentProducerTemplate}} class, it looks like it 
mutates it's internal state in it's implementation of the methods of the 
{{FluentProducerTemplate}} interface. Because the builder isn't immutable, it 
would appear that any two threads using the same 
{{DefaultFluentProducerTemplate}} instance (as in the example in the 
description) would allow for any state changes from one thread to leak into the 
other.

In my case, it looks like the body is often getting swapped out with one from 
another thread, but it looks like any of the internal state could get mixed up 
since this class isn't immutable.  I'm not sure what the performance 
implications of making this class immutable would be, but that would definitely 
appear to be one way to solve the problem.

> DefaultFluentProducerTemplate is not thread safe
> 
>
> Key: CAMEL-12638
> URL: https://issues.apache.org/jira/browse/CAMEL-12638
> Project: Camel
>  Issue Type: Bug
>  Components: camel-core
>Affects Versions: 2.20.2
>Reporter: Lukasz
>Priority: Major
>
> I think we have rediscovered the CAMEL-10820 bug. A body of one request gets 
> replaced with a body of proceeding request, in our case we use *request()* 
> method instead of *asyncSend()*.
> We use camel together with spring-boot. Consider following code:
>  
> {code:java}
> @Service
> public class UseCamelService {
>private FluentProducerTemplate producer;
>@Autowired
>public UseCamelService(FluentProducerTemplate producer) {
>   this.producer = producer;
>}
>public String getValueFromCamel(String body) {
>   return producer.to("route").withBody(body).request(String.class);
>}
> }
> {code}
> If *UseCamelService.getValueFromCamel()* gets called from two different 
> threads it is possible for the latter one to override the body of the first 
> one.



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