You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/02/24 18:04:45 UTC

svn commit: r1074216 - /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java

Author: jbellis
Date: Thu Feb 24 17:04:45 2011
New Revision: 1074216

URL: http://svn.apache.org/viewvc?rev=1074216&view=rev
Log:
avoid non-positive BufferSize.  this + previous exposes a bug in EOF handling

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java?rev=1074216&r1=1074215&r2=1074216&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/io/util/BufferedRandomAccessFile.java Thu Feb 24 17:04:45 2011
@@ -83,7 +83,7 @@ public class BufferedRandomAccessFile ex
      */
     public BufferedRandomAccessFile(String name, String mode) throws IOException
     {
-        this(new File(name), mode, 0);
+        this(new File(name), mode, DEFAULT_BUFFER_SIZE);
     }
 
     public BufferedRandomAccessFile(String name, String mode, int bufferSize) throws IOException
@@ -98,7 +98,7 @@ public class BufferedRandomAccessFile ex
      */
     public BufferedRandomAccessFile(File file, String mode) throws IOException
     {
-        this(file, mode, 0);
+        this(file, mode, DEFAULT_BUFFER_SIZE);
     }
 
     public BufferedRandomAccessFile(File file, String mode, int bufferSize) throws IOException
@@ -116,6 +116,8 @@ public class BufferedRandomAccessFile ex
         filePath = file.getAbsolutePath();
 
         // allocating required size of the buffer
+        if (bufferSize <= 0)
+            throw new IllegalArgumentException("bufferSize must be positive");
         buffer = ByteBuffer.allocate(bufferSize);
 
         // if in read-only mode, caching file size