cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobr...@apache.org
Subject cassandra git commit: Delete temp test files on exit
Date Thu, 11 Jan 2018 20:11:11 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 0ac5a17d3 -> 8587b0ceb


Delete temp test files on exit

patch by jasobrown; reviewed by Jay Zhuang for CASSANDRA-14153


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8587b0ce
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8587b0ce
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8587b0ce

Branch: refs/heads/trunk
Commit: 8587b0ceb47fa54308dfa9b0bfdc320e6afdc311
Parents: 0ac5a17
Author: Jason Brown <jasedbrown@gmail.com>
Authored: Wed Jan 10 05:40:54 2018 -0800
Committer: Jason Brown <jasedbrown@gmail.com>
Committed: Thu Jan 11 12:10:06 2018 -0800

----------------------------------------------------------------------
 CHANGES.txt                                                   | 1 +
 src/java/org/apache/cassandra/io/util/FileUtils.java          | 7 +++++++
 .../cassandra/io/compress/CompressedSequentialWriterTest.java | 2 +-
 test/unit/org/apache/cassandra/io/util/FileUtilsTest.java     | 2 +-
 test/unit/org/apache/cassandra/utils/BloomFilterTest.java     | 2 +-
 test/unit/org/apache/cassandra/utils/NativeLibraryTest.java   | 2 +-
 6 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8587b0ce/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bc2645f..e38cd70 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * Delete temp test files on exit (CASSANDRA-14153)
  * Make PartitionUpdate and Mutation immutable (CASSANDRA-13867)
  * Fix CommitLogReplayer exception for CDC data (CASSANDRA-14066)
  * Fix cassandra-stress startup failure (CASSANDRA-14106)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8587b0ce/src/java/org/apache/cassandra/io/util/FileUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/FileUtils.java b/src/java/org/apache/cassandra/io/util/FileUtils.java
index 5236fef..70595fc 100644
--- a/src/java/org/apache/cassandra/io/util/FileUtils.java
+++ b/src/java/org/apache/cassandra/io/util/FileUtils.java
@@ -118,6 +118,13 @@ public final class FileUtils
         return createTempFile(prefix, suffix, new File(System.getProperty("java.io.tmpdir")));
     }
 
+    public static File createDeletableTempFile(String prefix, String suffix)
+    {
+        File f = createTempFile(prefix, suffix, new File(System.getProperty("java.io.tmpdir")));
+        f.deleteOnExit();
+        return f;
+    }
+
     public static Throwable deleteWithConfirm(String filePath, boolean expect, Throwable
accumulate)
     {
         return deleteWithConfirm(new File(filePath), expect, accumulate);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8587b0ce/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
b/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
index dab2013..2accf87 100644
--- a/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
+++ b/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
@@ -177,7 +177,7 @@ public class CompressedSequentialWriterTest extends SequentialWriterTest
     public void resetAndTruncateTest()
     {
         File tempFile = new File(Files.createTempDir(), "reset.txt");
-        File offsetsFile = FileUtils.createTempFile("compressedsequentialwriter.offset",
"test");
+        File offsetsFile = FileUtils.createDeletableTempFile("compressedsequentialwriter.offset",
"test");
         final int bufferSize = 48;
         final int writeSize = 64;
         byte[] toWrite = new byte[writeSize];

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8587b0ce/test/unit/org/apache/cassandra/io/util/FileUtilsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/FileUtilsTest.java b/test/unit/org/apache/cassandra/io/util/FileUtilsTest.java
index 8821672..9a5c03a 100644
--- a/test/unit/org/apache/cassandra/io/util/FileUtilsTest.java
+++ b/test/unit/org/apache/cassandra/io/util/FileUtilsTest.java
@@ -47,7 +47,7 @@ public class FileUtilsTest
     @Test
     public void testTruncate() throws IOException
     {
-        File file = FileUtils.createTempFile("testTruncate", "1");
+        File file = FileUtils.createDeletableTempFile("testTruncate", "1");
         final String expected = "The quick brown fox jumps over the lazy dog";
 
         Files.write(file.toPath(), expected.getBytes());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8587b0ce/test/unit/org/apache/cassandra/utils/BloomFilterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/BloomFilterTest.java b/test/unit/org/apache/cassandra/utils/BloomFilterTest.java
index 07cbc5a..337e387 100644
--- a/test/unit/org/apache/cassandra/utils/BloomFilterTest.java
+++ b/test/unit/org/apache/cassandra/utils/BloomFilterTest.java
@@ -193,7 +193,7 @@ public class BloomFilterTest
     {
         ByteBuffer test = ByteBuffer.wrap(new byte[] {0, 1});
 
-        File file = FileUtils.createTempFile("bloomFilterTest-", ".dat");
+        File file = FileUtils.createDeletableTempFile("bloomFilterTest-", ".dat");
         BloomFilter filter = (BloomFilter) FilterFactory.getFilter(((long) Integer.MAX_VALUE
/ 8) + 1, 0.01d, true);
         filter.add(FilterTestHelper.wrap(test));
         DataOutputStreamPlus out = new BufferedDataOutputStreamPlus(new FileOutputStream(file));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8587b0ce/test/unit/org/apache/cassandra/utils/NativeLibraryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/NativeLibraryTest.java b/test/unit/org/apache/cassandra/utils/NativeLibraryTest.java
index 226653e..1a26351 100644
--- a/test/unit/org/apache/cassandra/utils/NativeLibraryTest.java
+++ b/test/unit/org/apache/cassandra/utils/NativeLibraryTest.java
@@ -30,7 +30,7 @@ public class NativeLibraryTest
     @Test
     public void testSkipCache()
     {
-        File file = FileUtils.createTempFile("testSkipCache", "1");
+        File file = FileUtils.createDeletableTempFile("testSkipCache", "1");
 
         NativeLibrary.trySkipCache(file.getPath(), 0, 0);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message