cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r941411 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/helpers/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ systests/databinding/src/test/java/org/apache/cxf...
Date Wed, 05 May 2010 18:19:11 GMT
Author: dkulp
Date: Wed May  5 18:19:11 2010
New Revision: 941411

URL: http://svn.apache.org/viewvc?rev=941411&view=rev
Log:
[CXF-2768] Make sure large inputstreams are closed on server side

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWs.java
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsImpl.java
    cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?rev=941411&r1=941410&r2=941411&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java Wed May  5
18:19:11 2010
@@ -41,7 +41,7 @@ public final class FileUtils {
         
     }
     
-    private static synchronized File getDefaultTempDir() {
+    public static synchronized File getDefaultTempDir() {
         if (defaultTempDir != null
             && defaultTempDir.exists()) {
             return defaultTempDir;

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java?rev=941411&r1=941410&r2=941411&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
Wed May  5 18:19:11 2010
@@ -20,6 +20,7 @@
 package org.apache.cxf.interceptor;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
@@ -57,6 +58,7 @@ public class OutgoingChainInterceptor ex
         Exchange ex = message.getExchange();
         BindingOperationInfo bin = ex.get(BindingOperationInfo.class);
         if (null != bin && null != bin.getOperationInfo() && bin.getOperationInfo().isOneWay())
{
+            closeInput(message);
             return;
         }
         Message out = ex.getOutMessage();
@@ -76,6 +78,18 @@ public class OutgoingChainInterceptor ex
         }
     }
     
+    private void closeInput(Message message) {
+        InputStream is = message.getContent(InputStream.class);
+        if (is != null) {
+            try {
+                is.close();
+                message.removeContent(InputStream.class);
+            } catch (IOException ioex) {
+                //ignore
+            }
+        }
+    }
+
     protected static Conduit getBackChannelConduit(Message message) {
         Conduit conduit = null;
         Exchange ex = message.getExchange();

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=941411&r1=941410&r2=941411&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Wed May  5 18:19:11 2010
@@ -560,6 +560,27 @@ public abstract class AbstractHTTPDestin
                                new WrappedOutputStream(message, response));
             }
         }
+        
+        @Override
+        public void close(Message msg) throws IOException {
+            super.close(msg);
+            if (msg.getExchange() == null) {
+                return;
+            }
+            Message m = msg.getExchange().getInMessage();
+            if (m == null || msg.getExchange().isOneWay()) {
+                return;
+            }
+            InputStream is = m.getContent(InputStream.class);
+            if (is != null) {
+                try {
+                    is.close();
+                    m.removeContent(InputStream.class);
+                } catch (IOException ioex) {
+                    //ignore
+                }
+            }
+        }
     }
 
     /**
@@ -602,6 +623,21 @@ public abstract class AbstractHTTPDestin
                 wrappedStream.close();
                 response.flushBuffer();
             }
+            /*
+            try {
+                //make sure the input stream is also closed in this 
+                //case so that any resources it may have is cleaned up
+                Message m = outMessage.getExchange().getInMessage();
+                if (m != null) {
+                    InputStream ins = m.getContent(InputStream.class);
+                    if (ins != null) {
+                        ins.close();
+                    }
+                }
+            } catch (IOException ex) {
+                //ignore
+            }
+            */
         }
         
         public void flush() throws IOException {

Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWs.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWs.java?rev=941411&r1=941410&r2=941411&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWs.java
(original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWs.java
Wed May  5 18:19:11 2010
@@ -54,4 +54,7 @@ public interface AegisJaxWs {
     //try comment this method
     @WebMethod
     java.util.List<String> getStringList();
+    
+    @WebMethod
+    java.util.List<String> echoBigList(java.util.List<String> l);
 }

Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsImpl.java?rev=941411&r1=941410&r2=941411&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsImpl.java
(original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsImpl.java
Wed May  5 18:19:11 2010
@@ -61,4 +61,9 @@ public class AegisJaxWsImpl implements A
     public List<String> getStringList() {
         return Arrays.asList("a", "b", "c");
     }
+    
+    public java.util.List<String> echoBigList(java.util.List<String> l) {
+        return l;
+    }
+
 }

Modified: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsTest.java?rev=941411&r1=941410&r2=941411&view=diff
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsTest.java
(original)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisJaxWsTest.java
Wed May  5 18:19:11 2010
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.systest.aegis;
 
+import java.io.File;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -26,6 +28,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.systest.aegis.bean.Item;
 import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
@@ -113,4 +116,22 @@ public class AegisJaxWsTest extends Abst
         List<String> item = client.getStringList();
         Assert.assertEquals(Arrays.asList("a", "b", "c"), item);
     }
+    @Test
+    public void testBigList() throws Exception {
+        int size = 1000;
+        List<String> l = new ArrayList<String>(size);
+        for (int x = 0; x < size; x++) {
+            l.add("Need to create a pretty big soap message to make sure we go over "
+                  + "some of the default buffer sizes and such so we can see what really"
+                  + "happens when we do that - " + x);
+        }
+        
+        setupForTest(false);
+        List<String> item = client.echoBigList(l);
+        Assert.assertEquals(size, item.size());
+        
+        //CXF-2768
+        File f = FileUtils.getDefaultTempDir();
+        Assert.assertEquals(0, f.listFiles().length);
+    }
 }



Mime
View raw message