cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1081649 - in /cxf/branches/2.3.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/attachment/ rt/core/src/test/java/org/apache/cxf/attachment/ systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/
Date Tue, 15 Mar 2011 02:47:03 GMT
Author: dkulp
Date: Tue Mar 15 02:47:03 2011
New Revision: 1081649

URL: http://svn.apache.org/viewvc?rev=1081649&view=rev
Log:
Merged revisions 1081648 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1081648 | dkulp | 2011-03-14 22:45:43 -0400 (Mon, 14 Mar 2011) | 4 lines
  
  [CXF-3383] In some very strange situations with several small
  attachments and read(buf, off, len) called with off != 0, the data at
  the end of various buffers can get lost and boundaries might not be
  found.
........

Added:
    cxf/branches/2.3.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data
      - copied unchanged from r1081648, cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data
    cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java
      - copied unchanged from r1081648, cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java
    cxf/branches/2.3.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java
      - copied unchanged from r1081648, cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java
Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
    cxf/branches/2.3.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java?rev=1081649&r1=1081648&r2=1081649&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
Tue Mar 15 02:47:03 2011
@@ -178,7 +178,7 @@ public class MimeBodyPartInputStream ext
                 //boundary matched (may or may not be last mime boundary)
                 int processed = initialI - off;
                 if ((len - (i + 2)) > 0) {
-                    inStream.unread(buffer, i + 2, len - (i + 2));
+                    inStream.unread(buffer, i + 2, len - (i + 2) + off);
                 }
                 return processed;
             }

Modified: cxf/branches/2.3.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=1081649&r1=1081648&r2=1081649&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Tue Mar 15 02:47:03 2011
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import javax.activation.DataSource;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
@@ -456,5 +457,42 @@ public class AttachmentDeserializerTest 
         }
         return bout.toString();
     }
+    
+    @Test
+    public void testCXF3383() throws Exception {
+        String contentType = "multipart/related; type=\"application/xop+xml\";"
+            + " boundary=\"uuid:7a555f51-c9bb-4bd4-9929-706899e2f793\"; start=" 
+            + "\"<root.message@cxf.apache.org>\"; start-info=\"text/xml\"";
+        
+        Message message = new MessageImpl();
+        message.put(Message.CONTENT_TYPE, contentType);
+        message.setContent(InputStream.class, getClass().getResourceAsStream("cxf3383.data"));
+        message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY, System
+                .getProperty("java.io.tmpdir"));
+        message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, String
+                .valueOf(AttachmentDeserializer.THRESHOLD));
+
+
+        AttachmentDeserializer ad 
+            = new AttachmentDeserializer(message, 
+                                         Collections.singletonList("multipart/related"));
+        
+        ad.initializeAttachments();
+        
+        
+        for (int x = 1; x < 50; x++) {
+            String cid = "1882f79d-e20a-4b36-a222-7a75518cf395-" + x + "@cxf.apache.org";
+            DataSource ds = AttachmentUtil.getAttachmentDataSource(cid, message.getAttachments());
+            byte bts[] = new byte[1024];
+            
+            InputStream ins = ds.getInputStream();
+            int count = ins.read(bts, 0, bts.length);
+            int sz = ins.read(bts, count, bts.length - count);
+            while (sz != -1) {
+                sz = ins.read(bts, count, bts.length - count);
+            }
+            assertEquals(x + 1, count);
+        }
+    }
 
 }
\ No newline at end of file



Mime
View raw message