diff --git a/CHANGES.txt b/CHANGES.txt index 03baa67ec6..130d712aac 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -32,7 +32,7 @@ per-CF FlushPeriodInMinutes setting (CASSANDRA-463) * Datacenter quorum consistency levels (CASSANDRA-492) * optimizations to slice reading (CASSANDRA-350) - + 0.4.2 * Add validation disallowing null keys (CASSANDRA-486) diff --git a/build.xml b/build.xml index 465aef74b2..9c1b3a3a07 100644 --- a/build.xml +++ b/build.xml @@ -37,7 +37,7 @@ - + diff --git a/src/java/org/apache/cassandra/io/SSTableReader.java b/src/java/org/apache/cassandra/io/SSTableReader.java index 36f2f1de68..e7e2d93423 100644 --- a/src/java/org/apache/cassandra/io/SSTableReader.java +++ b/src/java/org/apache/cassandra/io/SSTableReader.java @@ -189,30 +189,44 @@ public class SSTableReader extends SSTable implements Comparable private void loadBloomFilter() throws IOException { DataInputStream stream = new DataInputStream(new FileInputStream(filterFilename())); - bf = BloomFilter.serializer().deserialize(stream); + try + { + bf = BloomFilter.serializer().deserialize(stream); + } + finally + { + stream.close(); + } } private void loadIndexFile() throws IOException { BufferedRandomAccessFile input = new BufferedRandomAccessFile(indexFilename(), "r"); - indexPositions = new ArrayList(); - - int i = 0; - long indexSize = input.length(); - while (true) + try { - long indexPosition = input.getFilePointer(); - if (indexPosition == indexSize) + indexPositions = new ArrayList(); + + int i = 0; + long indexSize = input.length(); + while (true) { - break; - } - DecoratedKey decoratedKey = partitioner.convertFromDiskFormat(input.readUTF()); - input.readLong(); - if (i++ % INDEX_INTERVAL == 0) - { - indexPositions.add(new KeyPosition(decoratedKey, indexPosition)); + long indexPosition = input.getFilePointer(); + if (indexPosition == indexSize) + { + break; + } + DecoratedKey decoratedKey = partitioner.convertFromDiskFormat(input.readUTF()); + input.readLong(); + if (i++ % INDEX_INTERVAL == 0) + { + indexPositions.add(new KeyPosition(decoratedKey, indexPosition)); + } } } + finally + { + input.close(); + } } /** get the position in the index file to start scanning to find the given key (at most indexInterval keys away) */