cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [cxf] 01/03: On HTTP error, XSLTOutInterceptor mangles the error and triggers a freeze of one minute
Date Tue, 08 Jan 2019 13:20:39 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit da83f001e29bbc0f44fe71581e1c7a32f1e570f3
Author: RĂ©da Housni Alaoui <reda.housnialaoui@gmail.com>
AuthorDate: Thu Dec 20 18:47:13 2018 +0100

    On HTTP error, XSLTOutInterceptor mangles the error and triggers a freeze of one minute
    
    (cherry picked from commit f4750c368fa90512d63442472611ba5982467f56)
---
 .../cxf/feature/transform/XSLTOutInterceptor.java    | 10 ++++++++--
 .../transform/feature/TransformFeatureTest.java      | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java b/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java
index 1562008..851822f 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java
@@ -159,7 +159,8 @@ public class XSLTOutInterceptor extends AbstractXSLTInterceptor {
 
         @Override
         public void onClose(CachedOutputStream wrapper) {
-            InputStream transformedStream = null;
+            InputStream transformedStream;
+            IOException exceptionOnClose = null;
             try {
                 transformedStream = XSLTUtils.transform(xsltTemplate, wrapper.getInputStream());
                 IOUtils.copyAndCloseInput(transformedStream, origStream);
@@ -169,9 +170,14 @@ public class XSLTOutInterceptor extends AbstractXSLTInterceptor {
                 try {
                     origStream.close();
                 } catch (IOException e) {
-                    LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+                    exceptionOnClose = e;
                 }
             }
+            
+            if (exceptionOnClose == null) {
+                return;
+            }
+            throw new Fault(exceptionOnClose);
         }
     }
 
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/transform/feature/TransformFeatureTest.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/transform/feature/TransformFeatureTest.java
index 7895a8e..b9c5fcd 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/transform/feature/TransformFeatureTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/transform/feature/TransformFeatureTest.java
@@ -63,6 +63,26 @@ public class TransformFeatureTest extends AbstractBusClientServerTestBase
{
     }
 
     @Test
+    public void testClientOutTransformationOnNonExistingEndpoint() {
+        Service service = Service.create(SERVICE_NAME);
+        String endpoint = "http://localhost:" + PORT + "/NonExistent";
+        service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpoint);
+
+        Echo port = service.getPort(PORT_NAME, Echo.class);
+        Client client = ClientProxy.getClient(port);
+        XSLTOutInterceptor outInterceptor = new XSLTOutInterceptor(XSLT_REQUEST_PATH);
+        client.getOutInterceptors().add(outInterceptor);
+
+        try {
+            port.echo("test");
+            fail("404 Not found was expected"); 
+        } catch (Exception e) { 
+            String exceptionMessage = e.getMessage();
+            assertTrue(exceptionMessage.toLowerCase().contains("404: not found")); 
+        } 
+    }
+
+    @Test
     public void testClientInTransformation() {
         Service service = Service.create(SERVICE_NAME);
         String endpoint = "http://localhost:" + PORT + "/EchoContext/EchoPort";


Mime
View raw message