Skip to content

Commit

Permalink
add asserts. patch by jbellis for CASSANDRA-466
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Oct 2, 2009
1 parent f629a26 commit f264871
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/java/org/apache/cassandra/io/IndexHelper.java
Expand Up @@ -60,7 +60,8 @@ public static int skipBloomFilter(DataInput in) throws IOException
int size = in.readInt();
totalBytesRead += 4;
/* skip the serialized bloom filter */
in.skipBytes(size);
if (in.skipBytes(size) != size)
throw new EOFException();
totalBytesRead += size;
return totalBytesRead;
}
Expand All @@ -78,7 +79,8 @@ private static int skipIndex(DataInput file) throws IOException
int totalBytesRead = 4;

/* skip the column index data */
file.skipBytes(columnIndexSize);
if (file.skipBytes(columnIndexSize) != columnIndexSize)
throw new EOFException();
totalBytesRead += columnIndexSize;

return totalBytesRead;
Expand Down
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/io/SSTableWriter.java
Expand Up @@ -97,6 +97,7 @@ public void append(String decoratedKey, DataOutputBuffer buffer) throws IOExcept
long currentPosition = beforeAppend(decoratedKey);
dataFile.writeUTF(decoratedKey);
int length = buffer.getLength();
assert length > 0;
dataFile.writeInt(length);
dataFile.write(buffer.getData(), 0, length);
afterAppend(decoratedKey, currentPosition);
Expand All @@ -106,6 +107,7 @@ public void append(String decoratedKey, byte[] value) throws IOException
{
long currentPosition = beforeAppend(decoratedKey);
dataFile.writeUTF(decoratedKey);
assert value.length > 0;
dataFile.writeInt(value.length);
dataFile.write(value);
afterAppend(decoratedKey, currentPosition);
Expand Down

0 comments on commit f264871

Please sign in to comment.