cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject cassandra git commit: Fix detected leaks in unit tests
Date Tue, 14 Apr 2015 19:35:40 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 0df28d14a -> 1f65a12c3


Fix detected leaks in unit tests

Patch by Stefania Alborghetti; reviewed by Tyler Hobbs for
CASSANDRA-9134


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

Branch: refs/heads/trunk
Commit: 1f65a12c33e730b9f5bd56e6c8d00ed39bc456a1
Parents: 0df28d1
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Tue Apr 14 14:34:38 2015 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Tue Apr 14 14:35:30 2015 -0500

----------------------------------------------------------------------
 .../io/sstable/format/SSTableReader.java        | 22 +++++++++++---------
 .../cassandra/io/sstable/IndexSummaryTest.java  |  1 +
 2 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1f65a12c/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
index 24540b8..7b39266 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
@@ -386,17 +386,19 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
                 statsMetadata, OpenReason.NORMAL);
 
         // special implementation of load to use non-pooled SegmentedFile builders
-        SegmentedFile.Builder ibuilder = new BufferedSegmentedFile.Builder();
-        SegmentedFile.Builder dbuilder = sstable.compression
+        try(SegmentedFile.Builder ibuilder = new BufferedSegmentedFile.Builder();
+            SegmentedFile.Builder dbuilder = sstable.compression
                 ? new CompressedSegmentedFile.Builder(null)
-                : new BufferedSegmentedFile.Builder();
-        if (!sstable.loadSummary(ibuilder, dbuilder))
-            sstable.buildSummary(false, ibuilder, dbuilder, false, Downsampling.BASE_SAMPLING_LEVEL);
-        sstable.ifile = ibuilder.complete(sstable.descriptor.filenameFor(Component.PRIMARY_INDEX));
-        sstable.dfile = dbuilder.complete(sstable.descriptor.filenameFor(Component.DATA));
-        sstable.bf = FilterFactory.AlwaysPresent;
-        sstable.setup(true);
-        return sstable;
+                : new BufferedSegmentedFile.Builder())
+        {
+            if (!sstable.loadSummary(ibuilder, dbuilder))
+                sstable.buildSummary(false, ibuilder, dbuilder, false, Downsampling.BASE_SAMPLING_LEVEL);
+            sstable.ifile = ibuilder.complete(sstable.descriptor.filenameFor(Component.PRIMARY_INDEX));
+            sstable.dfile = dbuilder.complete(sstable.descriptor.filenameFor(Component.DATA));
+            sstable.bf = FilterFactory.AlwaysPresent;
+            sstable.setup(true);
+            return sstable;
+        }
     }
 
     private static SSTableReader open(Descriptor descriptor,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1f65a12c/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
index 6471558..7442a22 100644
--- a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
@@ -90,6 +90,7 @@ public class IndexSummaryTest
         assertEquals(dis.readUTF(), "JUNK");
         is.close();
         FileUtils.closeQuietly(dis);
+        random.right.close();
     }
 
     @Test


Mime
View raw message