Repository: cxf Updated Branches: refs/heads/master 4c4ce8b73 -> e1ef05eb5
[CXF-5630] If the client sets the ROBUST_ONEWAY flag, process any fault returned. Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e1ef05eb Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e1ef05eb Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e1ef05eb Branch: refs/heads/master Commit: e1ef05eb5825ae458d1afadffa737ff7fcd9466f Parents: 4c4ce8b Author: Daniel Kulp <[email protected]> Authored: Fri Mar 21 13:17:46 2014 -0400 Committer: Daniel Kulp <[email protected]> Committed: Fri Mar 21 13:18:28 2014 -0400 ---------------------------------------------------------------------- .../apache/cxf/transport/http/HTTPConduit.java | 21 ++++++++++---------- .../interceptor/InterceptorFaultTest.java | 7 ++++--- 2 files changed, 15 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/e1ef05eb/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java ---------------------------------------------------------------------- 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 f5cd040..115463f 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 @@ -1525,7 +1525,7 @@ public abstract class HTTPConduit } /** - * This predicate returns true iff the exchange indicates + * This predicate returns true if the exchange indicates * a oneway MEP. * * @param exchange The exchange in question @@ -1534,13 +1534,16 @@ public abstract class HTTPConduit return exchange != null && exchange.isOneWay(); } - private boolean doProcessResponse(Message message) { + private boolean doProcessResponse(Message message, int responseCode) { // 1. Not oneWay if (!isOneway(message.getExchange())) { return true; } - // 2. Context property - return MessageUtils.getContextualBoolean(message, Message.PROCESS_ONEWAY_RESPONSE, false); + // 2. Robust OneWays could have a fault + if (responseCode == 500 && MessageUtils.getContextualBoolean(message, Message.ROBUST_ONEWAY, false)) { + return true; + } + return false; } protected void handleResponseInternal() throws IOException { @@ -1574,10 +1577,11 @@ public abstract class HTTPConduit updateResponseHeaders(inMessage); inMessage.put(Message.RESPONSE_CODE, responseCode); - if (isOneway(exchange) + if (!doProcessResponse(outMessage, responseCode) || HttpURLConnection.HTTP_ACCEPTED == responseCode) { in = getPartialResponse(); - if ((in == null) || !doProcessResponse(outMessage)) { + if (in == null + || !MessageUtils.getContextualBoolean(outMessage, Message.PROCESS_ONEWAY_RESPONSE, false)) { // oneway operation or decoupled MEP without // partial response closeInputStream(); @@ -1593,12 +1597,9 @@ public abstract class HTTPConduit cc.handleResponse(null, null); } } - if (in != null) { - in.close(); - } exchange.setInMessage(inMessage); return; - } + } } else { //not going to be resending or anything, clear out the stuff in the out message //to free memory http://git-wip-us.apache.org/repos/asf/cxf/blob/e1ef05eb/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java index 271bde4..ec7ae3d 100644 --- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java +++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java @@ -30,6 +30,7 @@ import java.util.logging.Logger; import javax.xml.namespace.QName; import javax.xml.ws.Endpoint; import javax.xml.ws.WebServiceException; +import javax.xml.ws.soap.SOAPFaultException; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; @@ -56,6 +57,7 @@ import org.apache.cxf.testutil.common.AbstractBusTestServerBase; import org.apache.cxf.transport.http.HTTPConduit; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.apache.cxf.ws.addressing.MAPAggregator; + import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -203,9 +205,8 @@ public class InterceptorFaultTest extends AbstractBusClientServerTestBase { ((Client)greeter).getEndpoint().put(Message.ROBUST_ONEWAY, true); greeter.greetMeOneWay("oneway"); fail("Oneway operation unexpectedly succeded for phase " + location.getPhase()); - } catch (WebServiceException ex) { - // actually it should be instance of javax.xml.ws.soap.SOAPFaultException - assertEquals(FAULT_MESSAGE, ex.getMessage()); + } catch (SOAPFaultException ex) { + //expected } }
