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

dkulp pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.6.x-fixes by this push:
     new 84e8e3bbad Actually test that failover occured, fix failover with 
HttpClient based conduit
84e8e3bbad is described below

commit 84e8e3bbad1d69321aa4e783c2930ef1cc3ec32c
Author: Daniel Kulp <[email protected]>
AuthorDate: Fri May 26 11:55:47 2023 -0400

    Actually test that failover occured, fix failover with HttpClient based 
conduit
---
 .../java/org/apache/cxf/clustering/FailoverTargetSelector.java    | 8 +++++---
 .../src/main/java/org/apache/cxf/transport/http/HTTPConduit.java  | 3 +++
 .../java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java | 8 +++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git 
a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
 
b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
index 46ab74f3ba..6f7e11b2ce 100644
--- 
a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
+++ 
b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
@@ -305,9 +305,11 @@ public class FailoverTargetSelector extends 
AbstractConduitSelector {
 
     private Exception getExceptionIfPresent(Exchange exchange) {
         Message outMessage = exchange.getOutMessage();
-        return outMessage.get(Exception.class) != null
-            ? outMessage.get(Exception.class)
-                : exchange.get(Exception.class);
+        Exception ex = outMessage.get(Exception.class);
+        if (ex == null) {
+            ex = outMessage.getContent(Exception.class);
+        }
+        return ex != null ? ex : exchange.get(Exception.class);
     }
 
     /**
diff --git 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index 83fc672244..33b6157559 100644
--- 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -1217,6 +1217,9 @@ public abstract class HTTPConduit
                     } catch (Throwable e) {
                         
((PhaseInterceptorChain)outMessage.getInterceptorChain()).abort();
                         outMessage.setContent(Exception.class, e);
+                        if (e instanceof Exception) {
+                            outMessage.put(Exception.class, (Exception)e);
+                        }
                         
((PhaseInterceptorChain)outMessage.getInterceptorChain()).unwind(outMessage);
                         MessageObserver mo = 
outMessage.getInterceptorChain().getFaultObserver();
                         if (mo == null) {
diff --git 
a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
 
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
index df8e9d5636..ef91332e86 100644
--- 
a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
+++ 
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JaxwsAsyncFailOverTest.java
@@ -39,6 +39,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
 
 public class JaxwsAsyncFailOverTest  extends AbstractBusClientServerTestBase {
     static final String PORT = allocatePort(ServerNoBodyParts.class, 1);
@@ -106,12 +107,13 @@ public class JaxwsAsyncFailOverTest  extends 
AbstractBusClientServerTestBase {
 
         Response<GreetMeResponse>  response = proxy.greetMeAsync("cxf");
         int waitCount = 0;
-        while (!response.isDone() && waitCount < 15) {
-            Thread.sleep(1000);
+        while (!response.isDone() && waitCount < 150) {
+            Thread.sleep(100);
             waitCount++;
         }
         assertTrue("Response still not received.", response.isDone());
-
+        //make sure we actually got a proper response and not an exception
+        assertEquals("CXF", response.get().getResponseType());
     }
 
 }

Reply via email to