Author: ay
Date: Thu Jan 31 16:03:29 2013
New Revision: 1441035
URL: http://svn.apache.org/viewvc?rev=1441035&view=rev
Log:
Merged revisions 1441030 via svn merge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1441030 | ay | 2013-01-31 17:00:25 +0100 (Thu, 31 Jan 2013) | 1 line
[CXF-4797] CachedWriter may leave temp files undeleted
........
Added:
cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/io/CachedWriterTest.java
- copied unchanged from r1441030,
cxf/trunk/api/src/test/java/org/apache/cxf/io/CachedWriterTest.java
Modified:
cxf/branches/2.7.x-fixes/ (props changed)
cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/io/CachedWriter.java
cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
Propchange: cxf/branches/2.7.x-fixes/
('svn:mergeinfo' removed)
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/io/CachedWriter.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/io/CachedWriter.java?rev=1441035&r1=1441034&r2=1441035&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/io/CachedWriter.java
(original)
+++
cxf/branches/2.7.x-fixes/api/src/main/java/org/apache/cxf/io/CachedWriter.java
Thu Jan 31 16:03:29 2013
@@ -481,9 +481,8 @@ public class CachedWriter extends Writer
closed = true;
}
};
- Reader r = new InputStreamReader(fileInputStream, "UTF-8");
- streamList.add(r);
- return r;
+ streamList.add(fileInputStream);
+ return new InputStreamReader(fileInputStream, "UTF-8");
} catch (FileNotFoundException e) {
throw new IOException("Cached file was deleted, " +
e.toString());
}
Modified:
cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java?rev=1441035&r1=1441034&r2=1441035&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
(original)
+++
cxf/branches/2.7.x-fixes/api/src/test/java/org/apache/cxf/io/CachedOutputStreamTest.java
Thu Jan 31 16:03:29 2013
@@ -62,6 +62,25 @@ public class CachedOutputStreamTest exte
}
@Test
+ public void testDeleteTmpFile2() throws IOException {
+ CachedOutputStream cos = new CachedOutputStream();
+ //ensure output data size larger then 64k which will generate tmp file
+ String result = initTestData(65);
+ cos.write(result.getBytes());
+ //assert tmp file is generated
+ File tempFile = cos.getTempFile();
+ assertNotNull(tempFile);
+ assertTrue(tempFile.exists());
+ InputStream in = cos.getInputStream();
+ cos.close();
+ //assert tmp file is not deleted when the input stream is open
+ assertTrue(tempFile.exists());
+ in.close();
+ //assert tmp file is deleted after the input stream is closed
+ assertFalse(tempFile.exists());
+ }
+
+ @Test
public void testEncryptAndDecryptWithDeleteOnClose() throws IOException {
CachedOutputStream cos = new CachedOutputStream();
cos.setThreshold(4);