cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject cxf git commit: [CXF-7350]the exception should be able to return to client if retry is 0 with ws-rm
Date Fri, 28 Apr 2017 04:13:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 26314c27e -> fa4ae6a45


[CXF-7350]the exception should be able to return to client if retry is 0 with ws-rm

(cherry picked from commit c48c368f4622d88673dcc77c5726f5563f792b07)

Conflicts:
	rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java

(cherry picked from commit 1e99be66040884b233906fde7394896f2723da69)


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fa4ae6a4
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fa4ae6a4
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fa4ae6a4

Branch: refs/heads/3.0.x-fixes
Commit: fa4ae6a45df4207abee32493dc70b67dc208ae76
Parents: 26314c2
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Fri Apr 28 11:38:30 2017 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Fri Apr 28 12:12:53 2017 +0800

----------------------------------------------------------------------
 .../cxf/ws/rm/RetransmissionInterceptor.java    | 17 +++++---
 .../systest/ws/rm/RetransmissionQueueTest.java  | 46 ++++++++++++++++++++
 2 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fa4ae6a4/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java
index 3faca2b..47a245d 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionInterceptor.java
@@ -27,6 +27,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
+import org.apache.cxf.ws.rm.manager.RetryPolicyType;
 
 /**
  * Just absorbs faults which will be handled by retransmission.
@@ -67,11 +68,17 @@ public class RetransmissionInterceptor extends AbstractPhaseInterceptor<Message>
         if (null == os) {
             return;
         }
-        if (isFault) { 
-            // remove the exception set by the PhaseInterceptorChain so that the 
-            // error does not reach the client when retransmission is scheduled 
-            message.setContent(Exception.class, null);
-            message.getExchange().put(Exception.class, null); 
+        if (isFault) {
+            RetryPolicyType rmrp = null != manager.getSourcePolicy()
+                ? manager.getSourcePolicy().getRetryPolicy() : null;
+            int maxRetries = null != rmrp ? rmrp.getMaxRetries() : -1;
+            if (maxRetries != 0) {
+                // remove the exception set by the PhaseInterceptorChain so that the
+                // error does not reach the client when retransmission is scheduled
+                message.setContent(Exception.class, null);
+                message.getExchange().put(Exception.class, null);
+            }
+
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/fa4ae6a4/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
index dfcb2e4..94616e4 100644
--- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/RetransmissionQueueTest.java
@@ -34,6 +34,8 @@ import org.apache.cxf.systest.ws.util.ConnectionHelper;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.ws.rm.RMManager;
+import org.apache.cxf.ws.rm.manager.RetryPolicyType;
+import org.apache.cxf.ws.rm.manager.SourcePolicyType;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -135,5 +137,49 @@ public class RetransmissionQueueTest extends AbstractBusClientServerTestBase
{
         empty = manager.getRetransmissionQueue().isEmpty();
         assertTrue("RetransmissionQueue not cleared", empty);
     }
+    
+    @Test
+    public void testOnewayFaultHandlingWithoutRetry() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml");
+        BusFactory.setDefaultBus(bus);
+        LoggingInInterceptor in = new LoggingInInterceptor();
+        bus.getInInterceptors().add(in);
+        bus.getInFaultInterceptors().add(in);
+        LoggingOutInterceptor out = new LoggingOutInterceptor();
+        bus.getOutInterceptors().add(out);
+        bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new
Long(4000));
+        SourcePolicyType sourcePolicy = new SourcePolicyType();
+        RetryPolicyType retryP = new RetryPolicyType();
+        retryP.setMaxRetries(0);
+        sourcePolicy.setRetryPolicy(retryP);
+        bus.getExtension(RMManager.class).setSourcePolicy(sourcePolicy);
+        // an interceptor to simulate a transmission error
+        MessageLossSimulator loser = new MessageLossSimulator();
+        bus.getOutInterceptors().add(loser);
+
+        bus.getOutFaultInterceptors().add(out);
+
+        GreeterService gs = new GreeterService();
+        final Greeter greeter = gs.getGreeterPort();
+        updateAddressPort(greeter, PORT);
+        LOG.fine("Created greeter client.");
+
+        ConnectionHelper.setKeepAliveConnection(greeter, true);
+        loser.setMode(-1);
+        loser.setThrowsException(true);
+
+        try {
+            greeter.greetMeOneWay("oneway");
+            fail("no retransmission so catch an Exception");
+        } catch (Exception e) {
+            assertEquals("simulated transmission exception", e.getMessage());
+        }
+        Thread.sleep(6000);
+
+        RMManager manager = bus.getExtension(RMManager.class);
+        boolean empty = manager.getRetransmissionQueue().isEmpty();
+        assertFalse("RetransmissionQueue is empty", empty);
+    }
 
 }


Mime
View raw message