Author: dkulp Date: Wed Feb 15 03:01:01 2012 New Revision: 1244318 URL: http://svn.apache.org/viewvc?rev=1244318&view=rev Log: Merged revisions 1242819 via svn merge from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes
........ r1242819 | ay | 2012-02-10 10:27:22 -0500 (Fri, 10 Feb 2012) | 9 lines Merged revisions 1242739 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1242739 | ay | 2012-02-10 12:00:24 +0100 (Fri, 10 Feb 2012) | 1 line [CXF-4096] a robust in-only processing option for non-decoupled WS-A EP ........ ........ Modified: cxf/branches/2.4.x-fixes/ (props changed) cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java Propchange: cxf/branches/2.4.x-fixes/ ('svn:mergeinfo' removed) Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?rev=1244318&r1=1244317&r2=1244318&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java (original) +++ cxf/branches/2.4.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java Wed Feb 15 03:01:01 2012 @@ -51,6 +51,7 @@ import org.apache.cxf.jaxb.JAXBContextCa import org.apache.cxf.message.Exchange; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; +import org.apache.cxf.message.MessageUtils; import org.apache.cxf.service.model.BindingFaultInfo; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.EndpointInfo; @@ -399,8 +400,25 @@ public final class ContextUtils { Conduit backChannel = target.getBackChannel(inMessage, partialResponse, reference); - if (backChannel != null) { + boolean robust = + MessageUtils.isTrue(inMessage.getContextualProperty(Message.ROBUST_ONEWAY)); + + if (robust) { + // insert the executor in the exchange to fool the OneWayProcessorInterceptor + exchange.put(Executor.class, getExecutor(inMessage)); + // pause dispatch on current thread and resume... + inMessage.getInterceptorChain().pause(); + inMessage.getInterceptorChain().resume(); + MessageObserver faultObserver = inMessage.getInterceptorChain().getFaultObserver(); + if (null != inMessage.getContent(Exception.class) && null != faultObserver) { + // return the fault over the response fault channel + inMessage.getExchange().setOneWay(false); + faultObserver.onMessage(inMessage); + return; + } + } + // set up interceptor chains and send message InterceptorChain chain = fullResponse != null @@ -444,20 +462,22 @@ public final class ContextUtils { in.cacheInput(); } - // async service invocation required *after* a response - // has been sent (i.e. to a oneway, or a partial response - // to a decoupled twoway) + if (!robust) { + // async service invocation required *after* a response + // has been sent (i.e. to a oneway, or a partial response + // to a decoupled twoway) - // pause dispatch on current thread ... - inMessage.getInterceptorChain().pause(); + // pause dispatch on current thread ... + inMessage.getInterceptorChain().pause(); - // ... and resume on executor thread - getExecutor(inMessage).execute(new Runnable() { - public void run() { - inMessage.getInterceptorChain().resume(); - } - }); + // ... and resume on executor thread + getExecutor(inMessage).execute(new Runnable() { + public void run() { + inMessage.getInterceptorChain().resume(); + } + }); + } } } } catch (Exception e) { Modified: cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java?rev=1244318&r1=1244317&r2=1244318&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java (original) +++ cxf/branches/2.4.x-fixes/systests/uncategorized/src/test/java/org/apache/cxf/systest/interceptor/InterceptorFaultTest.java Wed Feb 15 03:01:01 2012 @@ -22,7 +22,6 @@ package org.apache.cxf.systest.intercept import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.logging.Logger; @@ -165,22 +164,18 @@ public class InterceptorFaultTest extend setupGreeter("org/apache/cxf/systest/interceptor/no-addr.xml", false); + control.setRobustInOnlyMode(robust); + + // all interceptors pass + testInterceptorsPass(); + // behaviour is identicial for all phases - Iterator<Phase> it = inPhases.iterator(); - Phase p = null; FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory() .createFaultLocation(); - while (it.hasNext()) { - p = it.next(); - location.setPhase(p.getName()); - if (Phase.PRE_LOGICAL.equals(p.getName())) { - continue; - } else if (Phase.POST_INVOKE.equals(p.getName())) { - break; - } - testFail(location, false, robust); - } + // test failure occuring before and after logical addressing interceptor + // won't get a fault in case of oneways non-robust for the latter (partial response already sent) + testInterceptorFail(inPhases, location, robust); } @Test @@ -188,62 +183,60 @@ public class InterceptorFaultTest extend testWithAddressingAnonymousReplies(false); } + @Test + public void testRobustWithAddressingAnonymousReplies() throws Exception { + testWithAddressingAnonymousReplies(true); + } + private void testWithAddressingAnonymousReplies(boolean robust) throws Exception { setupGreeter("org/apache/cxf/systest/interceptor/addr.xml", false); - + + control.setRobustInOnlyMode(robust); + // all interceptors pass - greeter.greetMeOneWay("one"); - assertEquals("TWO", greeter.greetMe("two")); - try { - greeter.pingMe(); - fail("Expected PingMeFault not thrown."); - } catch (PingMeFault f) { - assertEquals(20, (int)f.getFaultInfo().getMajor()); - assertEquals(10, (int)f.getFaultInfo().getMinor()); - } + testInterceptorsPass(); // test failure in phases before Phase.PRE_LOGICAL - - Iterator<Phase> it = inPhases.iterator(); - Phase p = null; FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory() .createFaultLocation(); location.setAfter(MAPAggregator.class.getName()); - // test failure occuring before logical addressing interceptor - - while (it.hasNext()) { - p = it.next(); + // test failure occuring before and after logical addressing interceptor + // won't get a fault in case of oneways non-robust for the latter (partial response already sent) + testInterceptorFail(inPhases, location, robust); + } + + + private void testInterceptorFail(List<Phase> phases, FaultLocation location, boolean robust) + throws PingMeFault { + for (Phase p : phases) { location.setPhase(p.getName()); if (Phase.PRE_LOGICAL.equals(p.getName())) { + continue; + } else if (Phase.POST_INVOKE.equals(p.getName())) { break; } testFail(location, true, robust); } - - // test failure occuring after logical addressing interceptor - - // won't get a fault in case of oneways (partial response already sent) - - do { - location.setPhase(p.getName()); - if (Phase.INVOKE.equals(p.getName())) { - //faults from the PRE_LOGICAL and later phases won't make - //it back to the client, the 200/202 response has already - //been returned. The server has accepted the message - break; - } - testFail(location, true, robust); - p = it.hasNext() ? it.next() : null; - } while (null != p); } - - + + private void testInterceptorsPass() { + greeter.greetMeOneWay("one"); + assertEquals("TWO", greeter.greetMe("two")); + try { + greeter.pingMe(); + fail("Expected PingMeFault not thrown."); + } catch (PingMeFault f) { + assertEquals(20, f.getFaultInfo().getMajor()); + assertEquals(10, f.getFaultInfo().getMinor()); + } + } + private void testFail(FaultLocation location, boolean usingAddressing, boolean robust) throws PingMeFault { // System.out.print("Test interceptor failing in phase: " + location.getPhase()); control.setFaultLocation(location); - control.setRobustInOnlyMode(robust); // oneway reports a plain fault (although server sends a soap fault)
