Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EE0E7D774 for ; Mon, 22 Oct 2012 09:11:03 +0000 (UTC) Received: (qmail 64708 invoked by uid 500); 22 Oct 2012 09:11:03 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 64589 invoked by uid 500); 22 Oct 2012 09:11:02 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 64571 invoked by uid 99); 22 Oct 2012 09:11:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 09:11:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 09:10:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3830823888FD; Mon, 22 Oct 2012 09:10:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1400811 - in /cxf/trunk: api/src/main/java/org/apache/cxf/interceptor/ api/src/main/java/org/apache/cxf/io/ rt/transports/local/src/main/java/org/apache/cxf/transport/local/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ Date: Mon, 22 Oct 2012 09:10:12 -0000 To: commits@cxf.apache.org From: ay@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121022091013.3830823888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ay Date: Mon Oct 22 09:10:11 2012 New Revision: 1400811 URL: http://svn.apache.org/viewvc?rev=1400811&view=rev Log: [CXF-4592] Some tests are failing when COS's file caching is enforced Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original) +++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Mon Oct 22 09:10:11 2012 @@ -28,6 +28,7 @@ import org.apache.cxf.common.logging.Log import org.apache.cxf.helpers.IOUtils; import org.apache.cxf.io.CachedOutputStream; import org.apache.cxf.io.CachedWriter; +import org.apache.cxf.io.DelegatingInputStream; import org.apache.cxf.message.Message; import org.apache.cxf.phase.Phase; @@ -136,10 +137,21 @@ public class LoggingInInterceptor extend bos.setThreshold(threshold); } try { - IOUtils.copyAndCloseInput(is, bos); + // use the appropriate input stream and restore it later + InputStream bis = is instanceof DelegatingInputStream + ? ((DelegatingInputStream)is).getInputStream() : is; + + IOUtils.copyAndCloseInput(bis, bos); bos.flush(); + bis = bos.getInputStream(); + + // restore the delegating input stream or the input stream + if (is instanceof DelegatingInputStream) { + ((DelegatingInputStream)is).setInputStream(bis); + } else { + message.setContent(InputStream.class, bis); + } - message.setContent(InputStream.class, bos.getInputStream()); if (bos.getTempFile() != null) { //large thing on disk... buffer.getMessage().append("\nMessage (saved to tmp file):\n"); Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original) +++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Mon Oct 22 09:10:11 2012 @@ -89,8 +89,7 @@ public class CachedOutputStream extends } public CachedOutputStream() { - currentStream = new LoadingByteArrayOutputStream(2048); - inmem = true; + this(defaultThreshold); } public CachedOutputStream(long threshold) { Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java (original) +++ cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java Mon Oct 22 09:10:11 2012 @@ -65,6 +65,7 @@ public class LocalConduit extends Abstra message.setContent(OutputStream.class, stream); //save the original stream message.put(CachedOutputStream.class, stream); + stream.holdTempFile(); } } @@ -98,7 +99,8 @@ public class LocalConduit extends Abstra CachedOutputStream stream = message.get(CachedOutputStream.class); copy.setContent(InputStream.class, stream.getInputStream()); copy.removeContent(CachedOutputStream.class); - + stream.releaseTempFileHold(); + // Create a new incoming exchange and store the original exchange for the response ExchangeImpl ex = new ExchangeImpl(); ex.setInMessage(copy); Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java (original) +++ cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java Mon Oct 22 09:10:11 2012 @@ -121,6 +121,7 @@ public class LocalDestination extends Ab CachedOutputStream stream = new CachedOutputStream(); message.setContent(OutputStream.class, stream); message.setContent(CachedOutputStream.class, stream); + stream.holdTempFile(); } } @@ -136,6 +137,7 @@ public class LocalDestination extends Ab message.setContent(OutputStream.class, stream); MessageImpl.copyContent(message, copy); copy.setContent(InputStream.class, stream.getInputStream()); + stream.releaseTempFileHold(); if (exchange != null && exchange.getInMessage() == null) { exchange.setInMessage(copy); } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Mon Oct 22 09:10:11 2012 @@ -1923,9 +1923,10 @@ public class JAXRSClientServerBookTest e private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - return bos.getOut().toString(); + return str; } public static class ReplaceContentTypeInterceptor extends AbstractPhaseInterceptor { Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java Mon Oct 22 09:10:11 2012 @@ -223,9 +223,10 @@ public class JAXRSClientServerNonSpringB private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - return bos.getOut().toString(); + return str; } } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java Mon Oct 22 09:10:11 2012 @@ -158,10 +158,10 @@ public class JAXRSClientServerProxySprin private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - //System.out.println(bos.getOut().toString()); - return bos.getOut().toString(); + return str; } } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java Mon Oct 22 09:10:11 2012 @@ -108,10 +108,10 @@ public class JAXRSClientServerResourceCr private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - //System.out.println(bos.getOut().toString()); - return bos.getOut().toString(); + return str; } } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringBookTest.java Mon Oct 22 09:10:11 2012 @@ -99,10 +99,10 @@ public class JAXRSClientServerResourceCr private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - //System.out.println(bos.getOut().toString()); - return bos.getOut().toString(); + return str; } } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Mon Oct 22 09:10:11 2012 @@ -669,9 +669,10 @@ public class JAXRSClientServerSpringBook private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - return bos.getOut().toString(); + return str; } Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java Mon Oct 22 09:10:11 2012 @@ -741,9 +741,10 @@ public class JAXRSMultipartTest extends private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - return bos.getOut().toString(); + return str; } private Book readBookFromInputStream(InputStream is) throws Exception { Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=1400811&r1=1400810&r2=1400811&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Mon Oct 22 09:10:11 2012 @@ -892,9 +892,10 @@ public class JAXRSSoapBookTest extends A private String getStringFromInputStream(InputStream in) throws Exception { CachedOutputStream bos = new CachedOutputStream(); IOUtils.copy(in, bos); + String str = new String(bos.getBytes()); in.close(); bos.close(); - return bos.getOut().toString(); + return str; } private InputStream getHttpInputStream(String endpointAddress) throws Exception {