cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r554013 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/io/ common/xsd/ rt/core/src/main/java/org/apache/cxf/attachment/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt...
Date Fri, 06 Jul 2007 19:41:00 GMT
Author: dkulp
Date: Fri Jul  6 12:40:59 2007
New Revision: 554013

URL: http://svn.apache.org/viewvc?view=rev&rev=554013
Log:
Change some ByteArrayOutputStreams to CachedOutputStreams 
Update JAXB binding to load jaxb.index files if available

Added:
    incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/
    incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java
  (with props)
    incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/jaxb.index
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
    incubator/cxf/trunk/common/xsd/pom.xml
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Fri Jul
 6 12:40:59 2007
@@ -60,7 +60,7 @@
     }
 
     public CachedOutputStream() {
-        currentStream = new ByteArrayOutputStream();
+        currentStream = new ByteArrayOutputStream(2048);
         inmem = true;
     }
 
@@ -271,7 +271,14 @@
             }
         } else {
             try {
-                return new FileInputStream(tempFile);
+                return new FileInputStream(tempFile) {
+                    public void close() throws IOException {
+                        super.close();
+                        tempFile.delete();
+                        currentStream = new ByteArrayOutputStream();
+                        inmem = true;
+                    }
+                };
             } catch (FileNotFoundException e) {
                 throw new IOException("Cached file was deleted, " + e.toString());
             }

Modified: incubator/cxf/trunk/common/xsd/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/xsd/pom.xml?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/common/xsd/pom.xml (original)
+++ incubator/cxf/trunk/common/xsd/pom.xml Fri Jul  6 12:40:59 2007
@@ -84,5 +84,12 @@
         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/common/xsd</developerConnection>
       <url>http://svn.apache.org/viewvc/incubator/cxf/trunk/cxf-parent/cxf-common-xsd</url>
   </scm>
-
+    <!-- will remove this after it is got sync to central repository -->
+    <repositories>
+        <repository>
+            <id>java.net</id>
+            <url>http://download.java.net/maven/1/</url>
+            <layout>legacy</layout>
+        </repository>
+    </repositories>
 </project>

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
Fri Jul  6 12:40:59 2007
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.attachment;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PushbackInputStream;
@@ -130,7 +128,7 @@
     }
 
     private String findBoundaryFromInputStream() throws IOException {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        CachedOutputStream bos = new CachedOutputStream();
 
         InputStream is = message.getContent(InputStream.class);
         IOUtils.copy(is, bos);
@@ -140,7 +138,7 @@
         String msg = bos.toString();
 
         // Reset the input stream since we'll need it again later
-        message.setContent(InputStream.class, new ByteArrayInputStream(bos.toByteArray()));
+        message.setContent(InputStream.class, bos.getInputStream());
 
         // Use regex to get the boundary and return null if it's not found
         Matcher m = INPUT_STREAM_BOUNDARY_PATTERN.matcher(msg);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
Fri Jul  6 12:40:59 2007
@@ -18,16 +18,14 @@
  */
 package org.apache.cxf.interceptor;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -52,7 +50,7 @@
         }
 
         if (LOG.isLoggable(Level.INFO)) {
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            CachedOutputStream bos = new CachedOutputStream();
             try {
                 IOUtils.copy(is, bos);
 
@@ -61,27 +59,15 @@
 
                 LOG.info("Inbound Message\n" 
                          + "--------------------------------------\n"
-                         + bos.toString()
+                         + bos.getOut().toString()
                          + "\n--------------------------------------");
                 
-                message.setContent(InputStream.class, new ByteArrayInputStream(bos.toByteArray()));
+                message.setContent(InputStream.class, bos.getInputStream());
 
             } catch (IOException e) {
                 throw new Fault(e);
             }
         }
     }
-    
-    public static void copy(final InputStream input,
-                            final OutputStream output,
-                            final int bufferSize)
-        throws IOException {
-        final byte[] buffer = new byte[bufferSize];
-        int n = 0;
-        n = input.read(buffer);
-        while (-1 != n) {
-            output.write(buffer, 0, n);
-            n = input.read(buffer);
-        }
-    }
+
 }

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Fri Jul  6 12:40:59 2007
@@ -117,6 +117,9 @@
         } else {
             cls = JAXBUtils.getValidClass(cls);
             if (null != cls) {
+                if (classes.contains(cls)) {
+                    return;
+                }
                 if (cls.isEnum()) {
                     // The object factory stuff doesn't work for enums
                     classes.add(cls);

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBase.java
Fri Jul  6 12:40:59 2007
@@ -41,6 +41,10 @@
     protected boolean attachmentProcessingEnabled;
     protected boolean unwrapJAXBElement = true;
     
+    protected JAXBDataBase(JAXBContext ctx) {
+        context = ctx;
+    }
+    
     public void setSchema(Schema s) {
         this.schema = s;
     }

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Fri Jul  6 12:40:59 2007
@@ -19,7 +19,10 @@
 
 package org.apache.cxf.jaxb;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -58,6 +61,7 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.i18n.UncheckedException;
+import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.DataReader;
@@ -392,6 +396,50 @@
         Map<String, Object> map = new HashMap<String, Object>();
         if (defaultNs != null) {
             map.put("com.sun.xml.bind.defaultNamespaceRemap", defaultNs);
+        }
+        
+        //try and read any jaxb.index files that are with the other classes.  This should

+        //allow loading of extra classes (such as subclasses for inheritance reasons) 
+        //that are in the same package.
+        Map<String, InputStream> packages = new HashMap<String, InputStream>();
+        Map<String, ClassLoader> packageLoaders = new HashMap<String, ClassLoader>();
+        for (Class<?> jcls : classes) {
+            if (!packages.containsKey(PackageUtils.getPackageName(jcls))) {
+                packages.put(PackageUtils.getPackageName(jcls), jcls.getResourceAsStream("jaxb.index"));
+                packageLoaders.put(PackageUtils.getPackageName(jcls), jcls.getClassLoader());
+            }
+        }
+        for (Map.Entry<String, InputStream> entry : packages.entrySet()) {
+            if (entry.getValue() != null) {
+                try {
+                    BufferedReader reader = new BufferedReader(new InputStreamReader(entry.getValue(),
+                                                                                     "UTF-8"));
+                    String pkg = entry.getKey();
+                    ClassLoader loader = packageLoaders.get(pkg);
+                    if (!StringUtils.isEmpty(pkg)) {
+                        pkg += ".";
+                    }
+                    
+                    String line = reader.readLine();
+                    while (line != null) {
+                        line = line.trim();
+                        if (line.indexOf("#") != -1) {
+                            line = line.substring(0, line.indexOf("#"));
+                        }
+                        if (!StringUtils.isEmpty(line)) {
+                            try {
+                                Class<?> ncls = Class.forName(pkg + line, false, loader);
+                                classes.add(ncls);
+                            } catch (Exception e) {
+                                //ignore
+                            }
+                        }
+                        line = reader.readLine();
+                    }
+                } catch (Exception e) {
+                    //ignore
+                }
+            }
         }
         
         JAXBContext ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]),
map);

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Fri Jul  6 12:40:59 2007
@@ -29,7 +29,7 @@
 
 public class DataReaderImpl<T> extends JAXBDataBase implements DataReader<T>
{
     public DataReaderImpl(JAXBContext ctx) {
-        setJAXBContext(ctx);
+        super(ctx);
     }
 
     public Object read(T input) {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
Fri Jul  6 12:40:59 2007
@@ -28,7 +28,7 @@
 
 public class DataWriterImpl<T> extends JAXBDataBase implements DataWriter<T>
{
     public DataWriterImpl(JAXBContext ctx) {
-        setJAXBContext(ctx);
+        super(ctx);
     }
     
     public void write(Object obj, T output) {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
Fri Jul  6 12:40:59 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxb;
 
+
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -32,6 +33,7 @@
 import javax.wsdl.Service;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
+import javax.xml.bind.JAXBContext;
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLStreamReader;
@@ -39,6 +41,7 @@
 
 import org.w3c.dom.Node;
 
+import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.BindingFactoryManager;
@@ -47,6 +50,8 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxb.io.DataReaderImpl;
 import org.apache.cxf.jaxb.io.DataWriterImpl;
+import org.apache.cxf.jaxb_misc.ObjectFactory;
+import org.apache.cxf.jaxb_misc.TestJAXBClass;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.DestinationFactoryManager;
@@ -203,6 +208,18 @@
         assertEquals(jaxbDataBinding.getExtraClass().length, 2);
         assertEquals(jaxbDataBinding.getExtraClass()[0], GreetMe.class);
         assertEquals(jaxbDataBinding.getExtraClass()[1], GreetMeOneWay.class);
+    }
+    
+    @Test 
+    public void testJaxbIndex() throws Exception {
+        JAXBDataBinding db = new JAXBDataBinding();
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(ObjectFactory.class);
+        JAXBContext ctx = db.createJAXBContext(classes);
+        if (ctx instanceof JAXBContextImpl) {
+            JAXBContextImpl rictx = (JAXBContextImpl)ctx;
+            assertNotNull(rictx.getBeanInfo(TestJAXBClass.class));
+        }
     }
     
 }

Added: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java?view=auto&rev=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java
(added)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java
Fri Jul  6 12:40:59 2007
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxb_misc;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TestJAXBClass", propOrder = { "endPart" })
+public class TestJAXBClass {
+    @XmlElement(name = "EndPart", required = true)
+    protected String endPart;
+    
+    
+    public String getEndPart() {
+        return endPart;
+    }
+
+    public void setEndPart(String value) {
+        this.endPart = value;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/TestJAXBClass.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/jaxb.index
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/jaxb.index?view=auto&rev=554013
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/jaxb.index
(added)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb_misc/jaxb.index
Fri Jul  6 12:40:59 2007
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+TestJAXBClass

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?view=diff&rev=554013&r1=554012&r2=554013
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Fri Jul  6 12:40:59 2007
@@ -155,7 +155,7 @@
                 // TODO: make this streamable. This is one of my pet
                 // peeves in JAXB RI as well, so if you fix this, submit the 
                 // code to the JAXB RI as well (see RuntimeBuiltinLeafInfoImpl)! - DD
-                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                ByteArrayOutputStream bos = new ByteArrayOutputStream(2048);
                 Iterator<ImageWriter> writers = ImageIO.getImageWritersByMIMEType(ct);
                 if (writers.hasNext()) {
                     ImageWriter writer = writers.next();
@@ -219,9 +219,9 @@
             ds = (DataSource) o;
         } else if (o instanceof StreamSource) {
             StreamSource src = (StreamSource)o;
-            ByteArrayOutputStream bos = new ByteArrayOutputStream();
             try {
                 if (src.getInputStream() != null) {
+                    ByteArrayOutputStream bos = new ByteArrayOutputStream(2048);
                     IOUtils.copy(src.getInputStream(), bos, 1024);
                     ds = new ByteArrayDataSource(bos.toByteArray(), ct);
                 } else {



Mime
View raw message