geekzhu1314520 commented on a change in pull request #1354: Update 
BrokerOuterAPI.java
URL: https://github.com/apache/rocketmq/pull/1354#discussion_r310461740
 
 

 ##########
 File path: 
broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
 ##########
 @@ -123,7 +124,7 @@ public void updateNameServerAddressList(final String 
addrs) {
         final int timeoutMills,
         final boolean compressed) {
 
-        final List<RegisterBrokerResult> registerBrokerResultList = 
Lists.newArrayList();
+        final List<RegisterBrokerResult> registerBrokerResultList = 
Collections.synchronizedList(Lists.newArrayList());
 
 Review comment:
   registerBrokerResultList is not threa-safe in the code:
   ```
   for (final String namesrvAddr : nameServerAddressList) {
                   brokerOuterExecutor.execute(new Runnable() {
                       @Override
                       public void run() {
                           try {
                               RegisterBrokerResult result = 
registerBroker(namesrvAddr,oneway, timeoutMills,requestHeader,body);
                               if (result != null) {
                                   registerBrokerResultList.add(result);
                               }
   
                               log.info("register broker[{}]to name server {} 
OK", brokerId, namesrvAddr);
                           } catch (Exception e) {
                               log.warn("registerBroker Exception, {}", 
namesrvAddr, e);
                           } finally {
                               countDownLatch.countDown();
                           }
                       }
                   });
               }
   ```
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to