You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by wu...@apache.org on 2018/01/09 02:06:47 UTC

[incubator-servicecomb-java-chassis] 03/03: fix concurrent access breaks

This is an automated email from the ASF dual-hosted git repository.

wujimin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit e812ad79813250ea5fd241a388ba419d2603c789
Author: bao.liu <ba...@huawei.com>
AuthorDate: Mon Jan 8 15:05:15 2018 +0800

    fix concurrent access breaks
---
 .../java/io/servicecomb/serviceregistry/client/IpPortManager.java    | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/service-registry/src/main/java/io/servicecomb/serviceregistry/client/IpPortManager.java b/service-registry/src/main/java/io/servicecomb/serviceregistry/client/IpPortManager.java
index 12b4a00..6bd4b2a 100644
--- a/service-registry/src/main/java/io/servicecomb/serviceregistry/client/IpPortManager.java
+++ b/service-registry/src/main/java/io/servicecomb/serviceregistry/client/IpPortManager.java
@@ -75,9 +75,10 @@ public class IpPortManager {
   }
 
   public IpPort getNextAvailableAddress(IpPort failedIpPort) {
-    IpPort current = getAvailableAddress();
+    int currentIndex = currentAvailableIndex.get();
+    IpPort current = getAvailableAddress(currentIndex);
     if (current.equals(failedIpPort)) {
-      currentAvailableIndex.incrementAndGet();
+      currentAvailableIndex.compareAndSet(currentIndex, currentIndex + 1);
       current = getAvailableAddress();
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.