You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2017/11/23 18:23:32 UTC

[GitHub] joel-shemtov closed pull request #343: Modify error message on failure to close synchronous conduit

joel-shemtov closed pull request #343: Modify error message on failure to close synchronous conduit
URL: https://github.com/apache/cxf/pull/343
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
index 8288a70d353..eaa72e4c536 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
@@ -61,7 +61,8 @@ public void handleMessage(Message message) throws Fault {
             try {
                 getConduit(message).close(message);
             } catch (IOException e) {
-                throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_SEND", BUNDLE), e);
+                final String errMsg = message.getExchange().isSynchronous() ? "COULD_NOT_COMPLETE" : "COULD_NOT_SEND";
+                throw new Fault(new org.apache.cxf.common.i18n.Message(errMsg, BUNDLE), e);
             }
         }
     }
@@ -77,4 +78,4 @@ public static Conduit getConduit(Message message) throws IOException {
         return conduit;
     }
 
-}
\ No newline at end of file
+}
diff --git a/core/src/main/java/org/apache/cxf/interceptor/Messages.properties b/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
index 0b32feea3ea..48dba74142c 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
+++ b/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
@@ -29,6 +29,7 @@ NO_DATAREADER=No DataReader is available for Service: {0}
 NO_DATAWRITER=No DataWriter is available for Service: {0}
 COULD_NOT_UNRWAP=Could not unwrap message parts.
 COULD_NOT_SEND=Could not send Message.
+COULD_NOT_COMPLETE=Could not complete Exchange.
 NO_PART_FOUND=Message part {0} was not recognized.  (Does it exist in service WSDL?)
 ORDERED_PARAM_REQUIRED=Parameter should be ordered in the following sequence: {0}
 WRITE_ATTACHMENTS=Could not write attachments.
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
index 84394e6d23d..5994dff8436 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/schemavalidation/JavaFirstSchemaValidationTest.java
@@ -314,7 +314,9 @@ public void testRequestClientValidation() {
             disconnectedClient.saveValidateOut(person);
             fail("Expected exception");
         } catch (WebServiceException e) {
-            assertTrue(e.getMessage().contains("Could not send Message"));
+            final String exMessage = e.getMessage();
+            assertTrue(exMessage.contains("Could not send Message") 
+                       || exMessage.contains("Could not complete Exchange"));
         }
     }
 
diff --git a/systests/uncategorized/pom.xml b/systests/uncategorized/pom.xml
index da2510f4da7..4f283765ac3 100644
--- a/systests/uncategorized/pom.xml
+++ b/systests/uncategorized/pom.xml
@@ -415,6 +415,12 @@
             <artifactId>httpclient</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <version>1.3</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <profiles>
         <profile>
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/CircuitBreakerFailoverTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/CircuitBreakerFailoverTest.java
index f083aa3b686..c5b99d639f3 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/CircuitBreakerFailoverTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/clustering/CircuitBreakerFailoverTest.java
@@ -23,6 +23,8 @@
 import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.cxf.greeter_control.Greeter;
+import org.hamcrest.Matcher;
+import org.hamcrest.collection.IsIn;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -34,6 +36,9 @@
     private static final String FAILOVER_CONFIG =
             "org/apache/cxf/systest/clustering/circuit_breaker_failover.xml";
 
+    private final Matcher<String> isFaultMessage = 
+            new IsIn<>(new String[] {"Could not send Message.", "Could not complete Exchange."});
+
     protected String getConfig() {
         return FAILOVER_CONFIG;
     }
@@ -46,7 +51,7 @@ public void testWithNoAlternativeEndpoints() throws Exception {
             g.greetMe("fred");
             fail("Expecting communication exception");
         } catch (WebServiceException ex) {
-            assertThat(ex.getMessage(), equalTo("Could not send Message."));
+            assertThat(ex.getMessage(), isFaultMessage);
         }
 
         try {
@@ -73,7 +78,7 @@ public void testWithAlternativeEnpdpoints() throws Exception {
             g.greetMe("fred");
             fail("Expecting no alternative endpoints exception");
         } catch (WebServiceException ex) {
-            assertThat(ex.getMessage(), equalTo("Could not send Message."));
+            assertThat(ex.getMessage(), isFaultMessage);
         }
     }
 }
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 603c99cba8f..d109fe10036 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
@@ -59,6 +59,9 @@
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.apache.cxf.ws.addressing.MAPAggregator;
 
+import org.hamcrest.Matcher;
+import org.hamcrest.collection.IsIn;
+
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -76,6 +79,8 @@
                                                            "Server");
     private static final String FAULT_MESSAGE = "Could not send Message.";
 
+    private static final String COMPLETE_EXCHANGE_FAULT_MESSAGE = "Could not complete Exchange.";
+
     private static final String CONTROL_PORT_ADDRESS =
         "http://localhost:" + PORT + "/SoapContext/ControlPort";
 
@@ -136,6 +141,9 @@ public static void main(String[] args) {
     private PhaseComparator comparator;
     private Phase postUnMarshalPhase;
 
+    private final Matcher<String> isFaultMessage = 
+            new IsIn<>(new String[] {FAULT_MESSAGE, COMPLETE_EXCHANGE_FAULT_MESSAGE});
+
 
 
     @BeforeClass
@@ -313,7 +321,7 @@ private void testFail(FaultLocation location, boolean usingAddressing, boolean r
             if (!expectOnewayFault) {
                 fail("Oneway operation unexpectedly failed.");
             }
-            assertEquals(FAULT_MESSAGE, ex.getMessage());
+            assertThat(ex.getMessage(), isFaultMessage);
         }
 
         String expectedMsg = getExpectedInterceptorFaultMessage(location.getPhase());


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services