cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r583578 - in /incubator/cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/io/ common/common/src/main/java/org/apache/cxf/helpers/ rt/core/src/main/java/org/apache/cxf/attachment/ rt/core/src/main/java/org/apache/cxf/databinding/...
Date Wed, 10 Oct 2007 19:07:44 GMT
Author: dkulp
Date: Wed Oct 10 12:07:38 2007
New Revision: 583578

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

........
  r583312 | dkulp | 2007-10-09 18:13:54 -0400 (Tue, 09 Oct 2007) | 6 lines
  
  [CXF-986, CXF-1097] Part 1 - fix a bunch of issues that occur when message size exceeds the CachedOutputStream threshold.
  Still to investigate:
  1) It may now leak temp files.  Will check that tomorrow.
  2) SequenceTest hangs if threshold is very small (like 100 bytes).  Will investigate if this is a bug in the test or in the wsa/wsrm layer tomorrow.
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
    incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/CacheAndWriteOutputStream.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/WriteOnCloseOutputStream.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIConduitOutputStream.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportBase.java
    incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java
    incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java

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

Modified: incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Wed Oct 10 12:07:38 2007
@@ -26,17 +26,18 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.OutputStreamWriter;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
+import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.cxf.common.util.Base64Utility;
+import org.apache.cxf.helpers.IOUtils;
 
 public class CachedOutputStream extends OutputStream {
 
@@ -64,6 +65,12 @@
         inmem = true;
     }
 
+    public CachedOutputStream(long threshold) {
+        this.threshold = threshold; 
+        currentStream = new ByteArrayOutputStream(2048);
+        inmem = true;
+    }
+
     public void registerCallback(CachedOutputStreamCallback cb) {
         if (null == callbacks) {
             callbacks = new ArrayList<CachedOutputStreamCallback>();
@@ -147,7 +154,7 @@
         if (currentStream instanceof CachedOutputStream) {
             CachedOutputStream ac = (CachedOutputStream) currentStream;
             InputStream in = ac.getInputStream();
-            copyStream(in, out, (int) threshold);
+            IOUtils.copyAndCloseInput(in, out);
         } else {
             if (inmem) {
                 if (currentStream instanceof ByteArrayOutputStream) {
@@ -157,7 +164,7 @@
                     }
                 } else if (currentStream instanceof PipedOutputStream) {
                     PipedOutputStream pipeOut = (PipedOutputStream) currentStream;
-                    copyStream(new PipedInputStream(pipeOut), out, (int) threshold);
+                    IOUtils.copyAndCloseInput(new PipedInputStream(pipeOut), out);
                 } else {
                     throw new IOException("Unknown format of currentStream");
                 }
@@ -166,7 +173,7 @@
                 currentStream.close();
                 FileInputStream fin = new FileInputStream(tempFile);
                 if (copyOldContent) {
-                    copyStream(fin, out, (int) threshold);
+                    IOUtils.copyAndCloseInput(fin, out);
                 }
             }
         }
@@ -174,32 +181,60 @@
     }
 
     public static void copyStream(InputStream in, OutputStream out, int bufferSize) throws IOException {
-        byte[] buffer = new byte[bufferSize];
-        try {
-            int n = in.read(buffer);
-            while (n > 0) {
-                out.write(buffer, 0, n);
-                n = in.read(buffer);
+        IOUtils.copyAndCloseInput(in, out, bufferSize);
+    }
+
+    
+    public byte[] getBytes() throws IOException {
+        flush();
+        if (inmem) {
+            if (currentStream instanceof ByteArrayOutputStream) {
+                return ((ByteArrayOutputStream)currentStream).toByteArray();
+            } else {
+                throw new IOException("Unknown format of currentStream");
             }
-        } finally {
-            in.close();
+        } else {
+            // read the file
+            FileInputStream fin = new FileInputStream(tempFile);
+            return IOUtils.readBytesFromStream(fin);
         }
     }
-
-    public static void copyStreamWithBase64Encoding(InputStream in, OutputStream out, int bufferSize)
-        throws Exception {
-        OutputStreamWriter osw = new OutputStreamWriter(out);
-        byte[] buffer = new byte[bufferSize];
-        try {
-            int n = in.read(buffer, 0, bufferSize);
-            while (n > 0) {
-                Base64Utility.encode(buffer, 0, n, osw);
-                n = in.read(buffer, 0, bufferSize);
+    
+    public void writeCacheTo(OutputStream out) throws IOException {
+        flush();
+        if (inmem) {
+            if (currentStream instanceof ByteArrayOutputStream) {
+                ((ByteArrayOutputStream)currentStream).writeTo(out);
+            } else {
+                throw new IOException("Unknown format of currentStream");
             }
-        } finally {
-            in.close();
+        } else {
+            // read the file
+            FileInputStream fin = new FileInputStream(tempFile);
+            IOUtils.copyAndCloseInput(fin, out);
         }
     }
+    public void writeCacheTo(StringBuilder out) throws IOException {
+        flush();
+        if (inmem) {
+            if (currentStream instanceof ByteArrayOutputStream) {
+                out.append(((ByteArrayOutputStream)currentStream).toString());
+            } else {
+                throw new IOException("Unknown format of currentStream");
+            }
+        } else {
+            // read the file
+            FileInputStream fin = new FileInputStream(tempFile);
+            byte bytes[] = new byte[1024];
+            int x = fin.read(bytes);
+            while (x != -1) {
+                out.append(new String(bytes, 0, x));
+                x = fin.read(bytes);
+            }
+            fin.close();
+        }
+    }    
+    
 
     /**
      * @return the underlying output stream
@@ -213,11 +248,27 @@
     }
 
     public String toString() {
-        return new StringBuilder().append("[")
+        StringBuilder builder = new StringBuilder().append("[")
             .append(super.toString())
-            .append(" Content: ")
-            .append(currentStream.toString())
-            .append("]").toString();
+            .append(" Content: ");
+        
+        if (inmem) {
+            builder.append(currentStream.toString());
+        } else {
+            try {
+                Reader fin = new FileReader(tempFile);
+                char buf[] = new char[1024];
+                int x = fin.read(buf);
+                while (x > -1) {
+                    builder.append(buf, 0, x);
+                    x = fin.read(buf);
+                }
+                fin.close();
+            } catch (IOException e) {
+                //ignore
+            }
+        }
+        return builder.append("]").toString();
     }
 
     protected void onWrite() throws IOException {
@@ -265,7 +316,7 @@
     }
 
     public File getTempFile() {
-        return tempFile;
+        return tempFile != null && tempFile.exists() ? tempFile : null;
     }
 
     public InputStream getInputStream() throws IOException {
@@ -283,7 +334,10 @@
                 return new FileInputStream(tempFile) {
                     public void close() throws IOException {
                         super.close();
-                        tempFile.delete();
+                        if (tempFile != null) {
+                            tempFile.delete();
+                            //tempFile = null;
+                        }
                         currentStream = new ByteArrayOutputStream();
                         inmem = true;
                     }
@@ -295,8 +349,9 @@
     }
 
     public void dispose() {
-        if (!inmem) {
+        if (!inmem && tempFile != null) {
             tempFile.delete();
+            //tempFile = null;
         }
     }
 

Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/IOUtils.java Wed Oct 10 12:07:38 2007
@@ -40,7 +40,24 @@
         return copy(input, output, DEFAULT_BUFFER_SIZE);
     }
 
-    
+    public static int copyAndCloseInput(final InputStream input, final OutputStream output)
+        throws IOException {
+        try {
+            return copy(input, output, DEFAULT_BUFFER_SIZE);
+        } finally {
+            input.close();
+        }
+    }
+    public static int copyAndCloseInput(final InputStream input,
+                                        final OutputStream output,
+                                        int bufferSize)
+        throws IOException {
+        try {
+            return copy(input, output, bufferSize);
+        } finally {
+            input.close();
+        }
+    }
     public static int copy(final InputStream input,
                             final OutputStream output,
                             int bufferSize)
@@ -80,7 +97,7 @@
     public static String toString(final InputStream input) 
         throws IOException {
         
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
         int n = 0;
         n = input.read(buffer);
@@ -94,7 +111,7 @@
     public static String toString(final Reader input) 
         throws IOException {
         
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         final char[] buffer = new char[DEFAULT_BUFFER_SIZE];
         int n = 0;
         n = input.read(buffer);
@@ -102,6 +119,7 @@
             buf.append(new String(buffer, 0, n));
             n = input.read(buffer);
         }
+        input.close();
         return buf.toString();
     }
     

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java Wed Oct 10 12:07:38 2007
@@ -60,7 +60,7 @@
 
     private PushbackInputStream stream;
 
-    private String boundary;
+    private byte boundary[];
 
     private String contentType;
 
@@ -95,19 +95,20 @@
         }
 
         if (contentType.toLowerCase().indexOf("multipart/related") != -1) {
-            boundary = findBoundaryFromContentType(contentType);
-            if (null == boundary) {                
-                boundary = findBoundaryFromInputStream();
+            String boundaryString = findBoundaryFromContentType(contentType);
+            if (null == boundaryString) {                
+                boundaryString = findBoundaryFromInputStream();
             }
             // If a boundary still wasn't found, throw an exception
-            if (null == boundary) {
+            if (null == boundaryString) {
                 throw new IOException("Couldn't determine the boundary from the message!");
             }
+            boundary = boundaryString.getBytes();
 
             stream = new PushbackInputStream(message.getContent(InputStream.class),
-                    boundary.getBytes().length * 2);
-            if (!readTillFirstBoundary(stream, boundary.getBytes())) {
-                throw new IOException("Couldn't find MIME boundary: " + boundary);
+                    boundary.length * 2);
+            if (!readTillFirstBoundary(stream, boundary)) {
+                throw new IOException("Couldn't find MIME boundary: " + new String(boundary));
             }
 
             try {
@@ -117,7 +118,7 @@
                 throw new RuntimeException(e);
             }
 
-            body = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary.getBytes()));
+            body = new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary));
             message.setContent(InputStream.class, body);
         }
     }
@@ -129,17 +130,16 @@
     }
 
     private String findBoundaryFromInputStream() throws IOException {
-        CachedOutputStream bos = new CachedOutputStream();
-        
         InputStream is = message.getContent(InputStream.class);
-        IOUtils.copy(is, bos);
-
-        is.close();
-        bos.close();
-        String msg = bos.toString();
-
+        //boundary should definitely be in the first 2K;
+        PushbackInputStream in = new PushbackInputStream(is, 4096);
+        byte buf[] = new byte[2048];
+        int i = in.read(buf);
+        String msg = new String(buf, 0, i);
+        in.unread(buf, 0, i);
+        
         // Reset the input stream since we'll need it again later
-        message.setContent(InputStream.class, bos.getInputStream());
+        message.setContent(InputStream.class, in);
 
         // Use regex to get the boundary and return null if it's not found
         Matcher m = INPUT_STREAM_BOUNDARY_PATTERN.matcher(msg);
@@ -281,7 +281,7 @@
      * @throws IOException
      */
     private void setupAttachment(AttachmentImpl att, InternetHeaders headers) throws IOException {
-        MimeBodyPartInputStream partStream = new MimeBodyPartInputStream(stream, boundary.getBytes());
+        MimeBodyPartInputStream partStream = new MimeBodyPartInputStream(stream, boundary);
 
         final String ct = headers.getHeader("Content-Type", null);
         DataSource source = new AttachmentDataSource(ct, new DelegatingInputStream(partStream));

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java Wed Oct 10 12:07:38 2007
@@ -56,12 +56,14 @@
         if (SAXSource.class.isAssignableFrom(type)) {
             try {
                 CachedOutputStream out = new CachedOutputStream();
-                XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
-                StaxUtils.copy(input, xsw);
-                xsw.close();
-                out.close();
-                
-                return new SAXSource(new InputSource(out.getInputStream()));
+                try {
+                    XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
+                    StaxUtils.copy(input, xsw);
+                    xsw.close();
+                    return new SAXSource(new InputSource(out.getInputStream()));
+                } finally {
+                    out.close();
+                }
             } catch (IOException e) {
                 throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
             } catch (XMLStreamException e) {
@@ -70,12 +72,14 @@
         } else if (StreamSource.class.isAssignableFrom(type)) {
             try {
                 CachedOutputStream out = new CachedOutputStream();
-                XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
-                StaxUtils.copy(input, xsw);
-                xsw.close();
-                out.close();
-                
-                return new StreamSource(out.getInputStream());
+                try {
+                    XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
+                    StaxUtils.copy(input, xsw);
+                    xsw.close();
+                    return new StreamSource(out.getInputStream());
+                } finally {
+                    out.close();
+                }
             } catch (IOException e) {
                 throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
             } catch (XMLStreamException e) {

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Wed Oct 10 12:07:38 2007
@@ -45,8 +45,10 @@
     public void handleMessage(Message message) throws Fault {
 
         if (LOG.isLoggable(Level.INFO)) {
-            StringBuffer buffer = new StringBuffer("Inbound Message\n" 
-                                                   + "--------------------------------------");
+            StringBuilder buffer = new StringBuilder(2048);
+            
+            buffer.append("Inbound Message\n")
+                .append("--------------------------------------");
             
             String encoding = (String)message.get(Message.ENCODING);
             if (encoding != null) {
@@ -63,13 +65,19 @@
                 try {
                     IOUtils.copy(is, bos);
 
+                    bos.flush();
                     is.close();
-                    bos.close();
 
-                    buffer.append("\nMessage:\n");
-                    buffer.append(bos.getOut().toString());
-                    
                     message.setContent(InputStream.class, bos.getInputStream());
+                    if (bos.getTempFile() != null) {
+                        //large thing on disk...
+                        buffer.append("\nMessage (saved to tmp file):\n");
+                        buffer.append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n");
+                    } else {            
+                        buffer.append("\nMessage:\n");
+                    }
+                    bos.writeCacheTo(buffer);
+                    bos.close();
                 } catch (IOException e) {
                     throw new Fault(e);
                 }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java Wed Oct 10 12:07:38 2007
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.interceptor;
 
-import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -49,6 +48,9 @@
         if (os == null) {
             return;
         }
+        if (!LOG.isLoggable(Level.INFO)) {
+            return;
+        }
         
         // Write the output while caching it for the log message
         final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os);
@@ -63,14 +65,24 @@
         }
         
         public void onClose(CachedOutputStream cos) {
-            OutputStream os = cos.getOut();
-            if (os instanceof ByteArrayOutputStream && LOG.isLoggable(Level.INFO)) {
-                // TODO - make this work with large messages
-                LOG.info("Outbound Message \n"
-                         + "--------------------------------------\n"
-                         + os.toString()
-                         + "\n--------------------------------------");
+            
+            StringBuilder buffer = new StringBuilder(2048);
+            
+            if (cos.getTempFile() == null) {
+                buffer.append("Outbound Message:\n");
+                buffer.append("--------------------------------------\n");
+            } else {
+                buffer.append("Outbound Message (saved to tmp file):\n");
+                buffer.append("Filename: " + cos.getTempFile().getAbsolutePath() + "\n");
+                buffer.append("--------------------------------------\n");
+            }
+            try {
+                cos.writeCacheTo(buffer);
+            } catch (Exception ex) {
+                //ignore
             }
+            buffer.append("--------------------------------------\n");
+            LOG.info(buffer.toString());
         }
         
     } 

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/CacheAndWriteOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/CacheAndWriteOutputStream.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/CacheAndWriteOutputStream.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/CacheAndWriteOutputStream.java Wed Oct 10 12:07:38 2007
@@ -37,6 +37,10 @@
         flowThroughStream = stream;
     }
 
+    public void closeFlowthroughStream() throws IOException {
+        flowThroughStream.flush();
+        flowThroughStream.close();
+    }
    
     protected void postClose() throws IOException {
         flowThroughStream.flush();

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/WriteOnCloseOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/WriteOnCloseOutputStream.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/WriteOnCloseOutputStream.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/io/WriteOnCloseOutputStream.java Wed Oct 10 12:07:38 2007
@@ -37,10 +37,9 @@
     }
 
     
-    protected void postClose() throws IOException {
+    protected void doClose() throws IOException {
         resetOut(flowThroughStream, true);
         flowThroughStream.flush();
-        flowThroughStream.close();
     }    
     
 }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/test/java/org/apache/cxf/transport/CachedOutputStreamTest.java Wed Oct 10 12:07:38 2007
@@ -19,6 +19,7 @@
 package org.apache.cxf.transport;
 
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.IOException;
 
 import org.apache.cxf.io.CachedOutputStream;
@@ -45,10 +46,12 @@
         String result = initTestData(65);
         cos.write(result.getBytes());
         //assert tmp file is generated
-        assertTrue(cos.getTempFile().exists());
+        File tempFile = cos.getTempFile();
+        assertNotNull(tempFile);
+        assertTrue(tempFile.exists());
         cos.close();
         //assert tmp file is deleted after close the CachedOutputStream
-        assertFalse(cos.getTempFile().exists());
+        assertFalse(tempFile.exists());
     }
     
     String initTestData(int packetSize) {

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Wed Oct 10 12:07:38 2007
@@ -19,7 +19,6 @@
 package org.apache.cxf.transport.http;
 
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -51,7 +50,6 @@
 import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.HttpHeaderHelper;
-import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.AbstractWrappedOutputStream;
 import org.apache.cxf.io.CacheAndWriteOutputStream;
 import org.apache.cxf.message.Exchange;
@@ -1580,21 +1578,15 @@
         
         // Trust is okay, write the cached request.
         OutputStream out = connection.getOutputStream();
-        
-        CacheAndWriteOutputStream.copyStream(stream.getInputStream(), out, 2048);
-        out.close();
+        stream.writeCacheTo(out);
         
         if (LOG.isLoggable(Level.FINE)) {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-            CacheAndWriteOutputStream.copyStream(stream.getInputStream(), 
-                    baos, 2048);
-
             LOG.fine("Conduit \""
                      + getConduitName() 
                      + "\" Retransmit message to: " 
                      + connection.getURL()
                      + ": "
-                     + baos.toString());
+                     + new String(stream.getBytes()));
         }
         return connection;
     }
@@ -1786,8 +1778,19 @@
                 handleHeadersTrustCaching();
             }
             super.flush();
-            super.close();
-            handleResponse();
+            if (!cachingForRetransmision) {
+                super.close();
+            } else {
+                cachedStream.getOut().close();
+                cachedStream.closeFlowthroughStream();
+            }
+            try {
+                handleResponse();
+            } finally {
+                if (cachingForRetransmision) {
+                    cachedStream.close();
+                }
+            }
         }
         
         
@@ -1801,15 +1804,12 @@
             if (cachedStream != null) {
 
                 if (LOG.isLoggable(Level.FINE)) {
-                    ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
-                    IOUtils.copy(cachedStream.getInputStream(), baos, 2048);
-
                     LOG.fine("Conduit \""
                              + getConduitName() 
                              + "\" Transmit cached message to: " 
                              + connection.getURL()
                              + ": "
-                             + baos.toString());
+                             + new String(cachedStream.getBytes()));
                 }
 
                 HttpURLConnection oldcon = connection;

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIConduitOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIConduitOutputStream.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIConduitOutputStream.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIConduitOutputStream.java Wed Oct 10 12:07:38 2007
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.transport.jbi;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Member;
@@ -157,15 +155,16 @@
 
             
 
+        } catch (IOException e) {
+            throw e;
         } catch (Exception e) {
             e.printStackTrace();
-            throw new IOException(e.toString());
+            new IOException(e.toString());
         }
     }
 
-    private Source getMessageContent(Message message2) {
-        ByteArrayOutputStream bos = (ByteArrayOutputStream)getOut();
-        return new StreamSource(new ByteArrayInputStream(bos.toByteArray()));
+    private Source getMessageContent(Message message2) throws IOException {
+        return new StreamSource(this.getInputStream());
         
     }
 

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/jbi/src/main/java/org/apache/cxf/transport/jbi/JBIDestinationOutputStream.java Wed Oct 10 12:07:38 2007
@@ -19,9 +19,8 @@
 
 package org.apache.cxf.transport.jbi;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -73,8 +72,7 @@
                 return;
             } else {
                 
-                ByteArrayOutputStream baos = (ByteArrayOutputStream)getOut();
-                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+                InputStream bais = getInputStream();
                 LOG.finest(new org.apache.cxf.common.i18n.Message(
                     "BUILDING.DOCUMENT", LOG).toString());
                 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java Wed Oct 10 12:07:38 2007
@@ -21,7 +21,6 @@
 
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -267,17 +266,7 @@
         }
         
         private void commitOutputMessage() throws JMSException {
-            Object request = null;            
-            
-            if (isTextPayload()) {
-                request = currentStream.toString();
-            } else {
-                request = ((ByteArrayOutputStream)currentStream).toByteArray();
-            }
-            
-            getLogger().log(Level.FINE, "Conduit Request is :[" + request + "]");
             javax.jms.Destination replyTo = pooledSession.destination();
-            
             //TODO setting up the responseExpected
             
             
@@ -288,6 +277,25 @@
                 replyTo = null;
             }
 
+            Object request = null;            
+            try {
+                if (isTextPayload()) {
+                    StringBuilder builder = new StringBuilder(2048);
+                    this.writeCacheTo(builder);
+                    request = builder.toString();
+                } else {
+                    request = getBytes();
+                }
+            } catch (IOException ex) {
+                JMSException ex2 = new JMSException("Error creating request");
+                ex2.setLinkedException(ex);
+                throw ex2;
+            }
+            if (getLogger().isLoggable(Level.FINE)) {
+                getLogger().log(Level.FINE, "Conduit Request is :[" + request + "]");
+            }
+            
+            
             jmsMessage = base.marshal(request, pooledSession.session(), replyTo,
                 getRuntimePolicy().getMessageType().value());
             

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java Wed Oct 10 12:07:38 2007
@@ -21,7 +21,6 @@
 
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -406,34 +405,34 @@
                     replySession = base.sessionFactory.get(false);
                     sender = (QueueSender)replySession.producer();
                     
+                    String msgType = JMSConstants.TEXT_MESSAGE_TYPE;
+                    Object replyObj = null;
+                    
                     if (request instanceof TextMessage) {
-                        reply = base.marshal(currentStream.toString(), 
-                                             replySession.session(), 
-                                             null, 
-                                             JMSConstants.TEXT_MESSAGE_TYPE);
-                        getLogger().log(Level.FINE,
-                                         "The response message is ["
-                                         + currentStream.toString() + "]");
+                        StringBuilder builder = new StringBuilder();
+                        this.writeCacheTo(builder);
+                        replyObj = builder.toString();
+                        msgType = JMSConstants.TEXT_MESSAGE_TYPE;
                     } else if (request instanceof BytesMessage) {
-                        reply = base.marshal(((ByteArrayOutputStream)currentStream).toByteArray(),
-                                             replySession.session(),
-                                             null, 
-                                             JMSConstants.BYTE_MESSAGE_TYPE);
-                        getLogger().log(Level.FINE, "The response message is [" 
-                                             + new String((
-                                                 (ByteArrayOutputStream)currentStream).toByteArray()) 
-                                             + "]");
+                        replyObj = getBytes();
+                        msgType = JMSConstants.BYTE_MESSAGE_TYPE;
                     } else {
-                        reply = base.marshal(((ByteArrayOutputStream)currentStream).toByteArray(),
-                                             replySession.session(),
-                                             null, 
-                                            JMSConstants.BINARY_MESSAGE_TYPE);
-                        getLogger().log(Level.FINE, "The response message is [" 
-                                             + new String((
-                                                 (ByteArrayOutputStream)currentStream).toByteArray()) 
-                                             + "]");
+                        replyObj = getBytes();
+                        msgType = JMSConstants.BINARY_MESSAGE_TYPE;
+                    }
+                    
+                    if (getLogger().isLoggable(Level.FINE)) {
+                        getLogger().log(Level.FINE, "The response message is ["
+                                        + (replyObj instanceof String 
+                                           ? (String)replyObj : new String((byte[])replyObj))
+                                    + "]");
                     }
-                   
+
+                    reply = base.marshal(replyObj, 
+                                         replySession.session(), 
+                                         null, 
+                                         msgType);
+
                     setReplyCorrelationID(request, reply);
                     
                     base.setMessageProperties(headers, reply);

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportBase.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportBase.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSTransportBase.java Wed Oct 10 12:07:38 2007
@@ -89,7 +89,6 @@
         } else if (JMSConstants.BYTE_MESSAGE_TYPE.equals(messageType)) {
             message = session.createBytesMessage();
             ((BytesMessage)message).writeBytes((byte[])payload);
-            
         } else {
             message = session.createObjectMessage();
             ((ObjectMessage)message).setObject((byte[])payload);

Modified: incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RetransmissionCallback.java Wed Oct 10 12:07:38 2007
@@ -19,8 +19,7 @@
 
 package org.apache.cxf.ws.rm;
 
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
+import java.io.IOException;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
@@ -48,34 +47,34 @@
         manager = mgr;
     }
     public void onClose(CachedOutputStream cos) {
-        OutputStream os = cos.getOut();
    
-        if (os instanceof ByteArrayOutputStream) {
-            ByteArrayOutputStream bos = (ByteArrayOutputStream)os;
-            message.put(RMMessageConstants.SAVED_OUTPUT_STREAM, bos);  
-            manager.getRetransmissionQueue().addUnacknowledged(message);
-            
-            RMStore store = manager.getStore();
-            if (null != store) {
-                Source s = manager.getSource(message);
-                RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
-                Identifier sid = rmps.getSequence().getIdentifier();
-                SourceSequence ss = s.getSequence(sid);
-                RMMessage msg = new RMMessage();
-                msg.setMessageNumber(rmps.getSequence().getMessageNumber());
-                if (!MessageUtils.isRequestor(message)) {
-                    AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, true);
-                    if (null != maps && null != maps.getTo()) {
-                        msg.setTo(maps.getTo().getValue());
-                    }
-                }
-                msg.setContent(bos.toByteArray());
-                store.persistOutgoing(ss, msg); 
-            }
-        } else {
+        message.put(RMMessageConstants.SAVED_OUTPUT_STREAM, cos.getOut());
+        byte bytes[] = null;
+        try {
+            bytes = cos.getBytes();
+        } catch (IOException e) {
             throw new Fault(new org.apache.cxf.common.i18n.Message("NO_CACHED_STREAM", 
                                                                    LOG, 
-                                                                   os.getClass()));
+                                                                   cos.getOut().getClass()));
+        }
+        manager.getRetransmissionQueue().addUnacknowledged(message);
+        
+        RMStore store = manager.getStore();
+        if (null != store) {
+            Source s = manager.getSource(message);
+            RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
+            Identifier sid = rmps.getSequence().getIdentifier();
+            SourceSequence ss = s.getSequence(sid);
+            RMMessage msg = new RMMessage();
+            msg.setMessageNumber(rmps.getSequence().getMessageNumber());
+            if (!MessageUtils.isRequestor(message)) {
+                AddressingProperties maps = RMContextUtils.retrieveMAPs(message, false, true);
+                if (null != maps && null != maps.getTo()) {
+                    msg.setTo(maps.getTo().getValue());
+                }
+            }
+            msg.setContent(bytes);
+            store.persistOutgoing(ss, msg); 
         }
     }
 

Modified: incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RetransmissionQueueImpl.java Wed Oct 10 12:07:38 2007
@@ -40,6 +40,7 @@
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.DeferredConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.io.CachedOutputStreamCallback;
 import org.apache.cxf.message.Message;
@@ -340,7 +341,7 @@
             ByteArrayInputStream bis = new ByteArrayInputStream(content);
 
             // copy saved output stream to new output stream in chunks of 1024
-            CachedOutputStream.copyStream(bis, os, 1024);
+            IOUtils.copyAndCloseInput(bis, os);
             os.flush();
             os.close();
         } catch (IOException ex) {

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java Wed Oct 10 12:07:38 2007
@@ -61,7 +61,7 @@
 import org.apache.hello_world.Greeter;
 import org.apache.hello_world.services.SOAPService;
 
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
@@ -193,13 +193,13 @@
         return server;
     }
     
-    @Before
-    public void setUp() {
+    @BeforeClass
+    public static void setProps() {
         // TODO: Do I need this?
         System.setProperty("org.apache.cxf.bus.factory", 
             "org.apache.cxf.bus.CXFBusFactory");
     }
-
+        
     public static KeyStore getKeyStore(String ksType, String file, String ksPassword)
         throws GeneralSecurityException,
                IOException {

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java Wed Oct 10 12:07:38 2007
@@ -36,7 +36,6 @@
 import org.apache.cxf.customer.book.GetAnotherBook;
 import org.apache.cxf.customer.book.GetBook;
 import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.junit.BeforeClass;
@@ -115,8 +114,9 @@
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123_xmlwrapped.txt");
 
+        String expectedString = getStringFromInputStream(expected);
         //System.out.println("---" + getStringFromInputStream(in));
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
+        assertEquals(expectedString, expectedString, getStringFromInputStream(in)); 
     }
     
     @Test
@@ -174,12 +174,7 @@
     }      
     
     private String getStringFromInputStream(InputStream in) throws Exception {        
-        CachedOutputStream bos = new CachedOutputStream();
-        IOUtils.copy(in, bos);
-        in.close();
-        bos.close();
-        //System.out.println(bos.getOut().toString());        
-        return bos.getOut().toString();        
+        return IOUtils.toString(in);
     }
 
 }

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/versioning/MediatorInInterceptor.java Wed Oct 10 12:07:38 2007
@@ -52,11 +52,10 @@
             return null;
         }
         //cache the input stream
-        CachedOutputStream bos = new CachedOutputStream();
+        CachedOutputStream bos = new CachedOutputStream(4096);
         try {
             IOUtils.copy(is, bos);
             is.close();
-            bos.close();
             
             message.setContent(InputStream.class, bos.getInputStream());
         
@@ -65,6 +64,7 @@
             XMLStreamReader xsr;
             xsr = StaxInInterceptor.getXMLInputFactory(message).
                 createXMLStreamReader(bos.getInputStream(), encoding);
+            
             // move to the soap body            
             while (true) {                
                 xsr.nextTag();              
@@ -91,6 +91,7 @@
                     return ep;
                 }
             }
+            bos.close();            
         } catch (Exception e) {
             throw new Fault(e);
         }    

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/rm/ClientPersistenceTest.java Wed Oct 10 12:07:38 2007
@@ -108,10 +108,18 @@
     public static void startServers() throws Exception {        
         String derbyHome = System.getProperty("derby.system.home");
         try {
-            System.setProperty("derby.system.home", derbyHome + "-server");
+            if (derbyHome == null) {
+                System.setProperty("derby.system.home", "derby-server");
+            } else {
+                System.setProperty("derby.system.home", derbyHome + "-server");                
+            }
             assertTrue("server did not launch correctly", launchServer(Server.class));
         } finally {
-            System.setProperty("derby.system.home", derbyHome);
+            if (derbyHome == null) {
+                System.clearProperty("derby.system.home");
+            } else {
+                System.setProperty("derby.system.home", derbyHome);
+            }
         }
         RMTxStore.deleteDatabaseFiles();
     }

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java?rev=583578&r1=583577&r2=583578&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/util/OutMessageRecorder.java Wed Oct 10 12:07:38 2007
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.systest.ws.util;
 
-import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -76,15 +75,15 @@
         
         public void onClose(CachedOutputStream cos) {
             // bytes were already copied after flush
-            OutputStream os = cos.getOut();
-            if (os instanceof ByteArrayOutputStream) {
-                ByteArrayOutputStream bos = (ByteArrayOutputStream)os;
-                outbound.add(bos.toByteArray());
+            try {
+                byte bytes[] = cos.getBytes();
                 if (LOG.isLoggable(Level.FINE)) {
-                    LOG.fine("outbound: " + bos.toString());
+                    LOG.fine("outbound: " + bytes);
                 }
-            } else {
-                LOG.fine("Can't record message from output stream class: " + os.getClass().getName());
+                outbound.add(bytes);
+            } catch (Exception e) {
+                LOG.fine("Can't record message from output stream class: "
+                         + cos.getOut().getClass().getName());
             }
         }
         



Mime
View raw message