You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ay...@apache.org on 2013/04/03 18:44:42 UTC

svn commit: r1464098 - in /cxf/trunk: api/src/main/java/org/apache/cxf/interceptor/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/

Author: ay
Date: Wed Apr  3 16:44:41 2013
New Revision: 1464098

URL: http://svn.apache.org/r1464098
Log:
[CXF-4941] WS-RM related faults do not contain the correct addressing action

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
    cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java?rev=1464098&r1=1464097&r2=1464098&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java Wed Apr  3 16:44:41 2013
@@ -88,8 +88,7 @@ public abstract class AbstractFaultChain
                     faultMessage.put(FaultMode.class, mode);
                 }
                 //CXF-3981
-                if (message.get("org.apache.cxf.ws.rm.inbound") == null 
-                    &&  message.get("javax.xml.ws.addressing.context.inbound") != null) {
+                if (message.get("javax.xml.ws.addressing.context.inbound") != null) {
                     faultMessage.put("javax.xml.ws.addressing.context.inbound",
                                      message.get("javax.xml.ws.addressing.context.inbound"));
                 }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?rev=1464098&r1=1464097&r2=1464098&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Wed Apr  3 16:44:41 2013
@@ -48,14 +48,13 @@ public class RMInInterceptor extends Abs
     @Override
     public void handleFault(Message message) {
         message.put(MAPAggregator.class.getName(), true);
-        if (null == RMContextUtils.getProtocolVariation(message)) {
-            return;
-        }
         if (MessageUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY))) {
             // revert the delivering entry from the destination sequence
             try {
                 Destination destination = getManager().getDestination(message);
-                destination.releaseDeliveringStatus(message);
+                if (destination != null) {
+                    destination.releaseDeliveringStatus(message);
+                }
             } catch (RMException e) {
                 LOG.log(Level.WARNING, "Failed to revert the delivering status");
             }
@@ -115,7 +114,7 @@ public class RMInInterceptor extends Abs
         String addrUri = maps.getNamespaceURI();
 
         ProtocolVariation protocol = ProtocolVariation.findVariant(rmUri, addrUri);
-        if (null == protocol) {
+        if (null == protocol && !MessageUtils.isFault(message)) {
             org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
                 "WSRM_REQUIRED_EXC", LOG, rmUri, addrUri);
             LOG.log(Level.INFO, msg.toString());

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java?rev=1464098&r1=1464097&r2=1464098&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java Wed Apr  3 16:44:41 2013
@@ -59,23 +59,27 @@ public class RMOutInterceptor extends Ab
     }
     
     protected void handle(Message msg) throws SequenceFault, RMException {  
-        if (isRuntimeFault(msg)) {
-            LogUtils.log(LOG, Level.WARNING, "RUNTIME_FAULT_MSG");
-            // TODO: in case of a SequenceFault need to set action
-            // to http://schemas.xmlsoap.org/ws/2004/a08/addressing/fault
-            // but: need to defer propagation of received MAPS to outbound chain first           
-            return;
-        }
-       
         AddressingProperties maps = ContextUtils.retrieveMAPs(msg, false, true,  false);
         if (null == maps) {
             LogUtils.log(LOG, Level.WARNING, "MAPS_RETRIEVAL_FAILURE_MSG");
             return;
         }
-        
-        Source source = getManager().getSource(msg);
         String rmUri = getManager().getRMNamespace(msg);
         String addrUri = getManager().getAddressingNamespace(msg);
+        if (isRuntimeFault(msg)) {
+            LogUtils.log(LOG, Level.WARNING, "RUNTIME_FAULT_MSG");
+            // in case of a SequenceFault or other WS-RM related fault, set action appropriately.
+            // the received inbound maps is available to extract some values in case if needed.
+            Throwable cause = msg.getContent(Exception.class).getCause();
+            if (cause instanceof SequenceFault || cause instanceof RMException) {
+                maps.getAction().setValue(RM11Constants.NAMESPACE_URI.equals(rmUri)
+                                          ? RM11Constants.NAMESPACE_URI + "/fault"
+                                          : addrUri + "/fault");
+            }
+            return;
+        }
+        
+        Source source = getManager().getSource(msg);
 
         ProtocolVariation protocol = ProtocolVariation.findVariant(rmUri, addrUri);
         RMContextUtils.setProtocolVariation(msg, protocol);

Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?rev=1464098&r1=1464097&r2=1464098&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java (original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java Wed Apr  3 16:44:41 2013
@@ -103,6 +103,8 @@ public class SequenceTest extends Abstra
         = "http://cxf.apache.org/greeter_control/Greeter/greetMeRequest";
     private static final String GREETME_RESPONSE_ACTION
         = "http://cxf.apache.org/greeter_control/Greeter/greetMeResponse";
+    private static final String RM10_GENERIC_FAULT_ACTION 
+        = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
 
     private static String decoupledEndpoint;
     private static int decoupledCount = 1;
@@ -795,7 +797,7 @@ public class SequenceTest extends Abstra
         mf.verifyMessages(3, false);
         expectedActions = new String[] {RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,
                                         GREETME_RESPONSE_ACTION, 
-                                        null};
+                                        RM10_GENERIC_FAULT_ACTION};
         mf.verifyActions(expectedActions, false);
         mf.verifyMessageNumbers(new String[] {null, "1", null}, false);
         mf.verifyAcknowledgements(new boolean[3] , false);
@@ -836,6 +838,10 @@ public class SequenceTest extends Abstra
         MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(),
             inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
         mf.verifySequenceFault(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME, false, 1);
+        String[] expectedActions = new String[3];
+        expectedActions = new String[] {RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,
+                                        RM10_GENERIC_FAULT_ACTION};
+        mf.verifyActions(expectedActions, false);
     }
     
     @Test
@@ -888,7 +894,7 @@ public class SequenceTest extends Abstra
         mf.verifyMessages(3, false);
         expectedActions = new String[] {RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,
                                         GREETME_RESPONSE_ACTION,
-                                        null};
+                                        RM10_GENERIC_FAULT_ACTION};
         mf.verifyActions(expectedActions, false);
         mf.verifyMessageNumbers(new String[] {null, "1", null}, false);
         mf.verifyAcknowledgements(new boolean[] {false, true, false} , false);