Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 68957 invoked from network); 16 Jun 2009 17:26:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Jun 2009 17:26:27 -0000 Received: (qmail 57998 invoked by uid 500); 16 Jun 2009 17:26:38 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 57922 invoked by uid 500); 16 Jun 2009 17:26:38 -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 57913 invoked by uid 99); 16 Jun 2009 17:26:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2009 17:26:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Tue, 16 Jun 2009 17:26:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C5E08238889D; Tue, 16 Jun 2009 17:26:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r785308 - in /cxf/branches/2.1.x-fixes: ./ api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Date: Tue, 16 Jun 2009 17:26:13 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090616172613.C5E08238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Tue Jun 16 17:26:13 2009 New Revision: 785308 URL: http://svn.apache.org/viewvc?rev=785308&view=rev Log: Merged revisions 785299 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes ................ r785299 | dkulp | 2009-06-16 13:08:03 -0400 (Tue, 16 Jun 2009) | 9 lines Merged revisions 785281 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r785281 | dkulp | 2009-06-16 12:21:35 -0400 (Tue, 16 Jun 2009) | 1 line [CXF-2289] If CachedOutputStream cannot create the file, continue with it in memory. ........ ................ Modified: cxf/branches/2.1.x-fixes/ (props changed) cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Propchange: cxf/branches/2.1.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jun 16 17:26:13 2009 @@ -1,2 +1,2 @@ -/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099,783407,784064,784197,785293,785296,785298 -/cxf/trunk:782181,782728-782730,783097,783396,784059,784181,784895,785279-785280 +/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099,783407,784064,784197,785293,785296,785298-785299 +/cxf/trunk:782181,782728-782730,783097,783396,784059,784181,784895,785279-785281 Propchange: cxf/branches/2.1.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=785308&r1=785307&r2=785308&view=diff ============================================================================== --- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original) +++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Tue Jun 16 17:26:13 2009 @@ -73,8 +73,8 @@ private boolean inmem; + private boolean tempFileFailed; private File tempFile; - private File outputDir = DEFAULT_TEMP_DIR; private List callbacks; @@ -241,7 +241,7 @@ public int size() { return totalLength; } - + public byte[] getBytes() throws IOException { flush(); if (inmem) { @@ -256,7 +256,7 @@ return IOUtils.readBytesFromStream(fin); } } - + public void writeCacheTo(OutputStream out) throws IOException { flush(); if (inmem) { @@ -278,7 +278,7 @@ writeCacheTo(out); return; } - + int count = 0; if (inmem) { if (currentStream instanceof ByteArrayOutputStream) { @@ -298,7 +298,7 @@ } out.append(IOUtils.newStringFromBytes(bytes, 0, x)); count += x; - + if (count >= limit) { x = -1; } else { @@ -328,8 +328,8 @@ } fin.close(); } - } - + } + /** * @return the underlying output stream @@ -355,7 +355,7 @@ } protected void onWrite() throws IOException { - + } public void write(byte[] b, int off, int len) throws IOException { @@ -392,17 +392,29 @@ } private void createFileOutputStream() throws IOException { + if (tempFileFailed) { + return; + } ByteArrayOutputStream bout = (ByteArrayOutputStream)currentStream; - if (outputDir == null) { - tempFile = FileUtils.createTempFile("cos", "tmp"); - } else { - tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false); + try { + if (outputDir == null) { + tempFile = FileUtils.createTempFile("cos", "tmp"); + } else { + tempFile = FileUtils.createTempFile("cos", "tmp", outputDir, false); + } + + currentStream = new BufferedOutputStream(new FileOutputStream(tempFile)); + bout.writeTo(currentStream); + inmem = false; + streamList.add(currentStream); + } catch (Exception ex) { + //Could be IOException or SecurityException or other issues. + //Don't care what, just keep it in memory. + tempFileFailed = true; + tempFile = null; + inmem = true; + currentStream = bout; } - - currentStream = new BufferedOutputStream(new FileOutputStream(tempFile)); - bout.writeTo(currentStream); - inmem = false; - streamList.add(currentStream); } public File getTempFile() {