Github user pasalkarsachin1 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1939#discussion_r101951192
  
    --- Diff: 
external/storm-kafka-client/src/main/java/org/apache/storm/kafka/trident/TridentKafkaState.java
 ---
    @@ -98,14 +107,19 @@ public void updateState(List<TridentTuple> tuples, 
TridentCollector collector) {
                 }
     
                 if(exceptions.size() > 0){
    -                String errorMsg = "Could not retrieve result for messages 
" + tuples + " from topic = " + topic 
    -                        + " because of the following exceptions: \n";
    -                for (ExecutionException exception : exceptions) {
    -                    errorMsg = errorMsg + exception.getMessage() + "\n";
    -                }
    -                LOG.error(errorMsg);
    -                throw new FailedException(errorMsg);
    -            }
    +           StringBuilder errorMsg = new StringBuilder("Could not retrieve 
result for messages ").append(tuples)
    --- End diff --
    
    If you read statement in stack overflow
    "However StringBuilder is useful if you are concatenating a large number of 
strings in a loop. It requires O(n2) time to run and creates many temporary 
strings."
     
    We also have same case. 
    ```java
    for (ExecutionException exception : exceptions) {
        errorMsg = 
errorMsg.append(exception.getMessage()).append(System.lineSeparator()); ;
     }
    ```
    So rather than having String above loop & then recreate StringBuilder 
object & created it initially.
    StringBuilder object 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to