cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [6/8] git commit: Do not try to write twice to output stream in robust one-way
Date Thu, 20 Mar 2014 17:07:23 GMT
Do not try to write twice to output stream in robust one-way


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

Branch: refs/heads/2.7.x-fixes
Commit: ece3d5c1f15ae57731f3caba4b47969e8de26fdb
Parents: c3d45a7
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
Authored: Thu Mar 20 14:52:05 2014 +0100
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Mar 20 13:06:46 2014 -0400

----------------------------------------------------------------------
 .../interceptor/OneWayProcessorInterceptor.java |  8 +----
 .../apache/cxf/phase/PhaseInterceptorChain.java |  3 ++
 .../interceptor/InterceptorFaultTest.java       | 34 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ece3d5c1/api/src/main/java/org/apache/cxf/interceptor/OneWayProcessorInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/OneWayProcessorInterceptor.java
b/api/src/main/java/org/apache/cxf/interceptor/OneWayProcessorInterceptor.java
index 1a026df..04f92e4 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/OneWayProcessorInterceptor.java
+++ b/api/src/main/java/org/apache/cxf/interceptor/OneWayProcessorInterceptor.java
@@ -36,7 +36,6 @@ import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.transport.Conduit;
-import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.workqueue.WorkQueueManager;
 
 
@@ -102,12 +101,7 @@ public class OneWayProcessorInterceptor extends AbstractPhaseInterceptor<Message
                 chain.pause();
                 chain.resume();
                 if (message.getContent(Exception.class) != null) {
-                    // return the fault over the response fault channel
-                    MessageObserver faultObserver = chain.getFaultObserver();
-                    if (faultObserver != null) {
-                        message.getExchange().setOneWay(false);
-                        faultObserver.onMessage(message);
-                    } 
+                    // CXF-5629 fault has been delivered alread in resume()
                     return;
                 }
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ece3d5c1/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java b/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
index c403e97..65d3b67 100644
--- a/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
+++ b/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
@@ -330,6 +330,9 @@ public class PhaseInterceptorChain implements InterceptorChain {
                         }
                         
                         if (faultObserver != null && !isOneWay) {
+                            // CXF-5629. when exchange is one way and robust, it becomes
req-resp in order to
+                            // send the fault
+                            message.getExchange().setOneWay(false);
                             faultObserver.onMessage(message);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ece3d5c1/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 3b1d10d..271bde4 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
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.systest.interceptor;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -44,6 +46,8 @@ import org.apache.cxf.greeter_control.Greeter;
 import org.apache.cxf.greeter_control.GreeterService;
 import org.apache.cxf.greeter_control.PingMeFault;
 import org.apache.cxf.greeter_control.types.FaultLocation;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseComparator;
 import org.apache.cxf.phase.PhaseManager;
@@ -174,6 +178,36 @@ public class InterceptorFaultTest extends AbstractBusClientServerTestBase
{
     public void testRobustWithoutAddressing() throws Exception {
         testWithoutAddressing(true);
     }
+    
+    @Test
+    public void testRobustFailWithoutAddressingInUserLogicalPhase() throws Exception {
+
+        setupGreeter("org/apache/cxf/systest/interceptor/no-addr.xml", false);
+
+        control.setRobustInOnlyMode(true);
+
+        // behaviour is identicial for all phases
+        FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory()
+            .createFaultLocation();
+        location.setPhase("user-logical");
+        
+        control.setFaultLocation(location);
+
+        try {
+            // writer to grab the content of soap fault.
+            // robust is not yet used at client's side, but I think it should
+            StringWriter writer = new StringWriter();
+            ((Client)greeter).getInInterceptors().add(new LoggingInInterceptor());
+            ((LoggingInInterceptor)greeterBus.getInInterceptors().get(0)).setPrintWriter(new
PrintWriter(writer));
+            // it should tell CXF to convert one-way robust out faults into real SoapFaultException
+            ((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());
+        }
+    }
 
     private void testWithoutAddressing(boolean robust) throws Exception {
         


Mime
View raw message