cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r746020 - in /cxf/trunk/rt/core/src: main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Date Thu, 19 Feb 2009 22:05:13 GMT
Author: dkulp
Date: Thu Feb 19 22:05:12 2009
New Revision: 746020

URL: http://svn.apache.org/viewvc?rev=746020&view=rev
Log:
[CXF-2050] Fix issue of not detecting ends of mime streams correctly

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java?rev=746020&r1=746019&r2=746020&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
Thu Feb 19 22:05:12 2009
@@ -142,7 +142,8 @@
                 if (initialI != off) {
                     i = 1000000000;
                 }
-                if (!hasData(buffer, initialI, i + 1, off, len)) {
+                if (initialI - off != 0 
+                    && !hasData(buffer, initialI, i + 1, off, len)) {
                     return initialI - off;
                 }
                 boundaryFound = true;

Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=746020&r1=746019&r2=746020&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
(original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Thu Feb 19 22:05:12 2009
@@ -22,6 +22,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.io.PushbackInputStream;
 import java.util.Collection;
 import java.util.Iterator;
 
@@ -277,4 +278,23 @@
         assertTrue(((DelegatingInputStream) attBody).getInputStream() instanceof FileInputStream);
         
     }
+    
+    
+    @Test
+    public void testSmallStream() throws Exception {
+        byte[] messageBytes = ("------=_Part_1\n\nJJJJ\n------=_Part_1\n\n"
+            + "Content-Transfer-Encoding: binary\n\n=3D=3D=3D\n------=_Part_1\n").getBytes();
+        PushbackInputStream pushbackStream = new PushbackInputStream(new ByteArrayInputStream(messageBytes),
+                                                                     2048);
+        pushbackStream.read(new byte[4096], 0, 4015);
+        pushbackStream.unread(messageBytes);
+        pushbackStream.read(new byte[72]);
+
+        MimeBodyPartInputStream m = new MimeBodyPartInputStream(pushbackStream, "------=_Part_1".getBytes(),
+                                                                2048);
+        
+        assertEquals(10, m.read(new byte[1000]));
+        assertEquals(-1, m.read(new byte[1000]));
+        assertEquals(-1, m.read(new byte[1000]));
+    }
 }
\ No newline at end of file



Mime
View raw message