reta commented on code in PR #954:
URL: https://github.com/apache/cxf/pull/954#discussion_r893908048


##########
rt/features/clustering/src/main/java/org/apache/cxf/clustering/RetryStrategy.java:
##########
@@ -42,7 +42,11 @@ public List<Endpoint> getAlternateEndpoints(Exchange 
exchange) {
     }
 
     protected <T> T getNextAlternate(List<T> alternates) {
-        return stillTheSameAddress() ? alternates.get(0) : 
alternates.remove(0);
+        // is the amount of retries for the first alternate already exceeded?
+        if (!stillTheSameAddress()) {
+            alternates.remove(0);
+        }
+        return alternates.isEmpty() ? null : alternates.get(0);

Review Comment:
   This is a great question, the suggestion I have in mind is not 100% bullet 
proof but I would love to hear your opinion:
   
   ```
   protected <T> T getNextAlternate(List<T> alternates) {
           String lastUsedAddress = null;
           // is the amount of retries for the first alternate already exceeded?
           if (!stillTheSameAddress()) {
               lastUsedAddress  = alternates.remove(0);
           }
           return alternates.isEmpty() ? lastUsedAddress : alternates.get(0);
   }
   ```
   
   In this case we would only go off the rails when there are no more 
alternatives to try out. WDYT?



-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@cxf.apache.org

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

Reply via email to