A bug in BufferedRandomAccessFile
---------------------------------

                 Key: CASSANDRA-2213
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2213
             Project: Cassandra
          Issue Type: Bug
    Affects Versions: 0.7.2
            Reporter: Leo Jay


The first line of BufferedRandomAccessFile.readAtMost is
{code}if (length >= bufferEnd && hitEOF){code}

I think It should be ">" instead of ">=",
Here is a test for this:{code}
    @Test
    public void testRead() throws IOException {
        File tmpFile = File.createTempFile("readtest", "bin");
        tmpFile.deleteOnExit();

        // Create the BRAF by filename instead of by file.
        BufferedRandomAccessFile rw = new 
BufferedRandomAccessFile(tmpFile.getPath(), "rw");
        rw.write(new byte[] {1});

        rw.seek(0);
        byte[] buffer = new byte[1];
        assert rw.read(buffer) == 1;
        assert buffer[0] == 1;
}
{code}

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to