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:40:01 UTC
[cxf] 01/02: 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 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 1823d59b20554658d4cfaac407d66d1c6923d57a
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
(cherry picked from commit 9c3dc283369f6c829b040920cbb93002daf3d440)
---
.../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 cee49ed4c9..eb70ed1caa 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 javax.xml.ws.Service;
import javax.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();