You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2022/07/07 17:39:34 UTC

[cxf] branch main updated: CXF-8735: AbstractStaticFailoverStrategy: UnsupportedOperationException when there are no services associated with the endpoint

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

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c3dc28336 CXF-8735: AbstractStaticFailoverStrategy: UnsupportedOperationException when there are no services associated with the endpoint
9c3dc28336 is described below

commit 9c3dc283369f6c829b040920cbb93002daf3d440
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Thu Jul 7 13:33:20 2022 -0400

    CXF-8735: AbstractStaticFailoverStrategy: UnsupportedOperationException when there are no services associated with the endpoint
---
 .../clustering/AbstractStaticFailoverStrategy.java  |  2 +-
 .../apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
index 68535cc9f6..09755dd8f6 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java
@@ -138,7 +138,7 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy
         // If there are no services associated with this endpoint (often in case of JAX-RS), 
         // returning the endpoint itself if allowed.
         if (services.isEmpty() && acceptCandidatesWithSameAddress) {
-            return Collections.singletonList(endpoint);
+            return new ArrayList<>(Collections.singleton(endpoint));
         }
         
         QName currentBinding = endpoint.getBinding().getBindingInfo().getName();
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
index cb651ece8d..bf31940820 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
@@ -43,6 +43,8 @@ import jakarta.xml.bind.Unmarshaller;
 import jakarta.xml.ws.Service;
 import jakarta.xml.ws.soap.SOAPBinding;
 import org.apache.cxf.Bus;
+import org.apache.cxf.clustering.FailoverFeature;
+import org.apache.cxf.clustering.RetryStrategy;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.ext.logging.LoggingInInterceptor;
 import org.apache.cxf.ext.logging.LoggingOutInterceptor;
@@ -917,6 +919,25 @@ public class JAXRSSoapBookTest extends AbstractBusClientServerTestBase {
         }
     }
 
+    @Test
+    public void testCheckBookClientErrorResponseWithFailover() {
+        final RetryStrategy retry = new RetryStrategy();
+        retry.setMaxNumberOfRetries(1);
+
+        final FailoverFeature failoverFeature = new FailoverFeature();
+        failoverFeature.setStrategy(retry);
+        
+        String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
+        BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress,
+                                          BookStoreJaxrsJaxws.class,
+                                          Collections.singletonList(new DummyResponseExceptionMapper()),
+                                          Collections.singletonList(failoverFeature),
+                                          null);
+        
+        Response response = proxy.checkBook(100L);
+        assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatus());
+    }
+
     private void serverFaultInInterceptorTest(String param) {
         String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
         JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();