CXF-8712: One-off issue with retries (fixing the test cases) main
authorAndriy Redko <drreta@gmail.com>
Fri, 30 Sep 2022 00:32:41 +0000 (20:32 -0400)
committerAndriy Redko <drreta@gmail.com>
Fri, 30 Sep 2022 00:33:18 +0000 (20:33 -0400)
rt/features/clustering/src/main/java/org/apache/cxf/clustering/RetryStrategy.java
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/failover/AbstractFailoverTest.java

index e8e3ec235a58fc7d8e61060d24d2bd542bb79fbb..8e823bb7cee352c62bc570b6750aa8c9a1314cce 100644 (file)
@@ -44,7 +44,7 @@ public class RetryStrategy extends SequentialStrategy {
     @Override
     protected <T> T getNextAlternate(List<T> alternates) {
         // is the amount of retries for the first alternate already exceeded?
-        if (!stillTheSameAddress()) {
+        if (!stillTheSameAddress() && !alternates.isEmpty()) {
             alternates.remove(0);
         }
         return alternates.isEmpty() ? null : alternates.get(0);
index 9ee204f0598adf8a8b7606880ee3900db1638efd..b5b323a157280c3d636825443b9820923631067b 100644 (file)
@@ -376,7 +376,7 @@ public abstract class AbstractFailoverTest extends AbstractBusClientServerTestBa
                 String address = (String)next;
                 Integer count = map.get(address);
                 if (count == null) {
-                    count = 0;
+                    count = map.isEmpty() ? 1 /* count first call */ : 0;
                 }
                 count++;
                 map.put(address, count);
@@ -389,7 +389,7 @@ public abstract class AbstractFailoverTest extends AbstractBusClientServerTestBa
         }
 
         public int getAddressCount(String address) {
-            return map.get(address);
+            return map.get(address) - 1;
         }
     }
 }