cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Mao <james....@iona.com>
Subject Re: svn commit: r605919 - in /incubator/cxf/trunk/rt/core/src: main/java/org/apache/cxf/attachment/AttachmentDataSource.java test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Date Fri, 21 Dec 2007 02:28:59 GMT
Just too hesitate to commit in, as I was testing against TCK.

Will do it soon, Thanks for pointing out :)

James

> Can this be changed to use the CachedOutputStream stream stuff?   We 
> shouldn't be storing attachments in memory as a byte[].   That can 
> easily suck up the entire memory causing all kinds of issues.
>
> Dan
>
> On Thursday 20 December 2007, mmao@apache.org wrote:
>   
>> Author: mmao
>> Date: Thu Dec 20 05:27:45 2007
>> New Revision: 605919
>>
>> URL: http://svn.apache.org/viewvc?rev=605919&view=rev
>> Log:
>> CXF-1313
>>   Cache the AttachmentDataSouce, so it can be reused multiple times,
>> not just read once.
>>
>>
>> Modified:
>>    
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/At
>> tachmentDataSource.java
>> incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/At
>> tachmentDeserializerTest.java
>>
>> Modified:
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/At
>> tachmentDataSource.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java
>> /org/apache/cxf/attachment/AttachmentDataSource.java?rev=605919&r1=6059
>> 18&r2=605919&view=diff
>> ======================================================================
>> ======== ---
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/At
>> tachmentDataSource.java (original) +++
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/At
>> tachmentDataSource.java Thu Dec 20 05:27:45 2007 @@ -19,20 +19,25 @@
>>
>>  package org.apache.cxf.attachment;
>>
>> +import java.io.ByteArrayInputStream;
>>  import java.io.IOException;
>>  import java.io.InputStream;
>>  import java.io.OutputStream;
>>
>>  import javax.activation.DataSource;
>>
>> +import org.apache.cxf.helpers.IOUtils;
>> +
>>  public class AttachmentDataSource implements DataSource {
>>
>>      private final String ct;
>>      private final InputStream in;
>> +    private final byte[] cache;
>>
>> -    public AttachmentDataSource(String ctParam, InputStream inParam)
>> { +    public AttachmentDataSource(String ctParam, InputStream
>> inParam) throws IOException { this.ct = ctParam;
>>          this.in = inParam;
>> +        cache = IOUtils.readBytesFromStream(in);
>>      }
>>
>>      public String getContentType() {
>> @@ -40,7 +45,7 @@
>>      }
>>
>>      public InputStream getInputStream() {
>> -        return in;
>> +        return new DelegatingInputStream(new
>> ByteArrayInputStream(cache)); }
>>
>>      public String getName() {
>>
>> Modified:
>> incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/At
>> tachmentDeserializerTest.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java
>> /org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=605919&r
>> 1=605918&r2=605919&view=diff
>> ======================================================================
>> ======== ---
>> incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/At
>> tachmentDeserializerTest.java (original) +++
>> incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/At
>> tachmentDeserializerTest.java Thu Dec 20 05:27:45 2007 @@ -75,7 +75,9
>> @@
>>
>>          InputStream attIs = a.getDataHandler().getInputStream();
>>
>> -        assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +        // We need to cache the
>> InputStream for reusing the AttachmentDataSource +       
>> //assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +       
>> assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof
>> ByteArrayInputStream); assertTrue(((DelegatingInputStream)
>> attBody).getInputStream() instanceof ByteArrayInputStream);
>>
>>          // check the cached output stream
>> @@ -122,7 +124,9 @@
>>
>>          InputStream attIs = a.getDataHandler().getInputStream();
>>
>> -        assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +        // We need to cache the
>> InputStream for reusing the AttachmentDataSource +       
>> //assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +       
>> assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof
>> ByteArrayInputStream); assertTrue(((DelegatingInputStream)
>> attBody).getInputStream() instanceof ByteArrayInputStream);
>>
>>          // check the cached output stream
>> @@ -168,8 +172,11 @@
>>          assertNotNull(a);
>>
>>          InputStream attIs = a.getDataHandler().getInputStream();
>> -
>> -        assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +
>> +        // We need to cache the InputStream for reusing the
>> AttachmentDataSource +        //assertTrue(((DelegatingInputStream)
>> attIs).getInputStream() instanceof MimeBodyPartInputStream); +       
>> assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof
>> ByteArrayInputStream); +
>>          assertTrue(((DelegatingInputStream) attBody).getInputStream()
>> instanceof ByteArrayInputStream);
>>
>>          // check the cached output stream
>> @@ -214,7 +221,9 @@
>>
>>          InputStream attIs = a.getDataHandler().getInputStream();
>>
>> -        assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +        // We need to cache the
>> InputStream for reusing the AttachmentDataSource +       
>> //assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +       
>> assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof
>> ByteArrayInputStream); assertTrue(((DelegatingInputStream)
>> attBody).getInputStream() instanceof ByteArrayInputStream);
>>
>>          // check the cached output stream
>> @@ -262,7 +271,9 @@
>>
>>          InputStream attIs = a.getDataHandler().getInputStream();
>>
>> -        assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +        // We need to cache the
>> InputStream for reusing the AttachmentDataSource +       
>> //assertTrue(((DelegatingInputStream) attIs).getInputStream()
>> instanceof MimeBodyPartInputStream); +       
>> assertTrue(((DelegatingInputStream) attIs).getInputStream() instanceof
>> ByteArrayInputStream); assertTrue(((DelegatingInputStream)
>> attBody).getInputStream() instanceof FileInputStream);
>>
>>      }
>>     
>
>
>
>   

Mime
View raw message