Skip to content

Instantly share code, notes, and snippets.

@cherron
Created October 16, 2012 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cherron/2f10efd3922fab9a095e to your computer and use it in GitHub Desktop.
Save cherron/2f10efd3922fab9a095e to your computer and use it in GitHub Desktop.
Patch for CASSANDRA-4571
Index: src/java/org/apache/cassandra/db/columniterator/SSTableSliceIterator.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/org/apache/cassandra/db/columniterator/SSTableSliceIterator.java (revision 4d2e5e73b127dc0b335176ddc1dec1f0244e7f6d)
+++ src/java/org/apache/cassandra/db/columniterator/SSTableSliceIterator.java (revision )
@@ -31,6 +31,7 @@
import org.apache.cassandra.db.IColumn;
import org.apache.cassandra.io.sstable.SSTableReader;
import org.apache.cassandra.io.util.FileDataInput;
+import org.apache.cassandra.io.util.FileUtils;
import org.apache.cassandra.utils.ByteBufferUtil;
/**
@@ -38,7 +39,7 @@
*/
public class SSTableSliceIterator implements ISSTableColumnIterator
{
- private final FileDataInput fileToClose;
+ private FileDataInput fileToClose = null;
private IColumnIterator reader;
private final SSTableReader sstable;
private DecoratedKey key;
@@ -47,12 +48,12 @@
{
this.sstable = sstable;
this.key = key;
- fileToClose = sstable.getFileDataInput(this.key);
- if (fileToClose == null)
- return;
try
{
+ fileToClose = sstable.getFileDataInput(this.key);
+ if (fileToClose == null)
+ return;
DecoratedKey keyInDisk = SSTableReader.decodeKey(sstable.partitioner,
sstable.descriptor,
ByteBufferUtil.readWithShortLength(fileToClose));
@@ -62,8 +63,14 @@
}
catch (IOException e)
{
+ FileUtils.closeQuietly(fileToClose);
sstable.markSuspect();
throw new IOError(e);
+ }
+ catch (AssertionError ae)
+ {
+ FileUtils.closeQuietly(fileToClose);
+ throw ae;
}
reader = createReader(sstable, fileToClose, startColumn, finishColumn, reversed);
Index: src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java (revision 4d2e5e73b127dc0b335176ddc1dec1f0244e7f6d)
+++ src/java/org/apache/cassandra/db/columniterator/SSTableNamesIterator.java (revision )
@@ -59,13 +59,14 @@
assert columns != null;
this.columns = columns;
this.key = key;
+ FileDataInput file = null;
- FileDataInput file = sstable.getFileDataInput(key);
+ try
+ {
+ file = sstable.getFileDataInput(key);
- if (file == null)
- return;
+ if (file == null)
+ return;
- try
- {
DecoratedKey keyInDisk = SSTableReader.decodeKey(sstable.partitioner,
sstable.descriptor,
ByteBufferUtil.readWithShortLength(file));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment