You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by az...@apache.org on 2009/07/24 13:40:04 UTC

svn commit: r797422 - /synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java

Author: azeez
Date: Fri Jul 24 11:40:03 2009
New Revision: 797422

URL: http://svn.apache.org/viewvc?rev=797422&view=rev
Log:
Synchronize based on algorithmContext


Modified:
    synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java

Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java?rev=797422&r1=797421&r2=797422&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java Fri Jul 24 11:40:03 2009
@@ -70,10 +70,10 @@
 
         Endpoint nextEndpoint;
         int attempts = 0;
-        int currentEPR = algorithmContext.getCurrentEndpointIndex();
-        do {
-            // two successive clients could get the same endpoint if not synchronized.
-            synchronized (this) {
+        synchronized (algorithmContext) {
+            int currentEPR = algorithmContext.getCurrentEndpointIndex();
+            do {
+                // two successive clients could get the same endpoint if not synchronized.
                 nextEndpoint = (Endpoint) endpoints.get(currentEPR);
 
                 if (currentEPR == endpoints.size() - 1) {
@@ -82,14 +82,14 @@
                     currentEPR++;
                 }
                 algorithmContext.setCurrentEndpointIndex(currentEPR);
-            }
 
-            attempts++;
-            if (attempts > endpoints.size()) {
-                return null;
-            }
+                attempts++;
+                if (attempts > endpoints.size()) {
+                    return null;
+                }
 
-        } while (!nextEndpoint.readyToSend());
+            } while (!nextEndpoint.readyToSend());
+        }
 
         return nextEndpoint;
     }