This is an automated email from the ASF dual-hosted git repository. dkulp 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 3753729093 Actually test that failover occured, fix failover with HttpClient based conduit 3753729093 is described below commit 37537290932d3d399819a223142ab190fbafd3f4 Author: Daniel Kulp <d...@kulp.com> 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 f14d968acb..1b4466cf1d 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 8bc5cfef0e..90671aaa35 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 @@ -37,6 +37,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class JaxwsAsyncFailOverTest extends AbstractBusClientServerTestBase { @@ -105,12 +106,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()); } }