You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/05/06 21:09:33 UTC

svn commit: r941863 - in /cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ transports/http/src/main/java/org/apache/cxf/transport/http/gzip/ transports/http/src/test/java/org/apache/cxf/transport/http/gzip/

Author: dkulp
Date: Thu May  6 19:09:32 2010
New Revision: 941863

URL: http://svn.apache.org/viewvc?rev=941863&view=rev
Log:
Update a couple of the stream interceptors to not barf completely if a
stream isn't there

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPInInterceptor.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPOutInterceptor.java
    cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/gzip/GZIPAcceptEncodingTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java?rev=941863&r1=941862&r2=941863&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentInInterceptor.java Thu May  6 19:09:32 2010
@@ -20,6 +20,7 @@
 package org.apache.cxf.interceptor;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.logging.Logger;
@@ -52,6 +53,9 @@ public class AttachmentInInterceptor ext
             LOG.fine("AttachmentInInterceptor skipped in HTTP GET method");
             return;
         }
+        if (message.getContent(InputStream.class) == null) {
+            return;
+        }
         
         String contentType = (String) message.get(Message.CONTENT_TYPE);
         if (AttachmentUtil.isTypeSupported(contentType, getSupportedTypes())) {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java?rev=941863&r1=941862&r2=941863&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AttachmentOutInterceptor.java Thu May  6 19:09:32 2010
@@ -20,6 +20,7 @@
 package org.apache.cxf.interceptor;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -56,6 +57,9 @@ public class AttachmentOutInterceptor ex
         if (!mtomEnabled && !writeAtts) {
             return;
         }
+        if (message.getContent(OutputStream.class) == null) {
+            return;
+        }
 
         AttachmentSerializer serializer = 
             new AttachmentSerializer(message, getMultipartType(), getRootHeaders());

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java?rev=941863&r1=941862&r2=941863&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java Thu May  6 19:09:32 2010
@@ -62,7 +62,9 @@ public class StaxInInterceptor extends A
             return;
         }
         InputStream is = message.getContent(InputStream.class);
-        assert is != null;
+        if (is == null) {
+            return;
+        }
 
         String contentType = (String)message.get(Message.CONTENT_TYPE);
         

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPInInterceptor.java?rev=941863&r1=941862&r2=941863&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPInInterceptor.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPInInterceptor.java Thu May  6 19:09:32 2010
@@ -73,6 +73,9 @@ public class GZIPInInterceptor extends A
                 try {
                     LOG.fine("Uncompressing response");
                     InputStream is = message.getContent(InputStream.class);
+                    if (is == null) {
+                        return;
+                    }
 
                     // wrap an unzipping stream around the original one
                     GZIPInputStream zipInput = new GZIPInputStream(is);

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPOutInterceptor.java?rev=941863&r1=941862&r2=941863&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPOutInterceptor.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/gzip/GZIPOutInterceptor.java Thu May  6 19:09:32 2010
@@ -119,6 +119,9 @@ public class GZIPOutInterceptor extends 
             // remember the original output stream, we will write compressed
             // data to this later
             OutputStream os = message.getContent(OutputStream.class);
+            if (os == null) {
+                return;
+            }
             message.put(ORIGINAL_OUTPUT_STREAM_KEY, os);
             message.put(USE_GZIP_KEY, use);
 

Modified: cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/gzip/GZIPAcceptEncodingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/gzip/GZIPAcceptEncodingTest.java?rev=941863&r1=941862&r2=941863&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/gzip/GZIPAcceptEncodingTest.java (original)
+++ cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/gzip/GZIPAcceptEncodingTest.java Thu May  6 19:09:32 2010
@@ -18,6 +18,10 @@
  */
 package org.apache.cxf.transport.http.gzip;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -59,8 +63,10 @@ public class GZIPAcceptEncodingTest exte
         Exchange exchange = new ExchangeImpl();
         exchange.setInMessage(inMessage);
         inMessage.setExchange(exchange);
+        inMessage.setContent(InputStream.class, new ByteArrayInputStream(new byte[0]));
         exchange.setOutMessage(outMessage);
         outMessage.setExchange(exchange);
+        outMessage.setContent(OutputStream.class, new ByteArrayOutputStream());
         outInterceptors = EasyMock.createMock(InterceptorChain.class);
         outMessage.setInterceptorChain(outInterceptors);
     }