You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/10/04 16:51:15 UTC

[GitHub] [camel] bedlaj commented on a change in pull request #4359: CAMEL-15626: Use StringBuilder instead of StringBuffer

bedlaj commented on a change in pull request #4359:
URL: https://github.com/apache/camel/pull/4359#discussion_r499265850



##########
File path: core/camel-base/src/main/java/org/apache/camel/processor/aggregate/StringAggregationStrategy.java
##########
@@ -63,12 +63,12 @@ public StringAggregationStrategy pick(Expression expression) {
      */
     @Override
     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
-        StringBuffer result; // Aggregate in StringBuffer instead of StringBuilder, to make it thread safe

Review comment:
       StringBuffer is here intentionally because it is mutable and ensures locks. As aggregate method can be called in many threads in parallel, you need to ensure locking in different way (synchronized block, ReentrantLock, ...) before changing this to StringBuilder, otherwise the output will be corrupted.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org