From bdba69ff8d59c975bdfb5ba60d3435c757633209 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Tue, 5 Apr 2011 17:27:01 +0000 Subject: [PATCH] Convert mmap assertion to if/throw patch by jbellis; reviewed by slebresne for CASSANDRA-2417 git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1089139 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/cassandra/io/util/MappedFileDataInput.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/cassandra/io/util/MappedFileDataInput.java b/src/java/org/apache/cassandra/io/util/MappedFileDataInput.java index a5e16cc800..5f410b6cbc 100644 --- a/src/java/org/apache/cassandra/io/util/MappedFileDataInput.java +++ b/src/java/org/apache/cassandra/io/util/MappedFileDataInput.java @@ -114,9 +114,9 @@ public class MappedFileDataInput extends AbstractDataInput implements FileDataIn public synchronized ByteBuffer readBytes(int length) throws IOException { int remaining = buffer.remaining() - position; - - assert length <= remaining - : String.format("mmap segment underflow; remaining is %d but %d requested", remaining, length); + if (length > remaining) + throw new IOException(String.format("mmap segment underflow; remaining is %d but %d requested", + remaining, length)); ByteBuffer bytes = buffer.duplicate(); bytes.position(buffer.position() + position).limit(buffer.position() + position + length);