Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-2213

A bug in BufferedRandomAccessFile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 0.7.3
    • None
    • None
    • Normal

    Description

      The first line of BufferedRandomAccessFile.readAtMost is

      if (length >= bufferEnd && hitEOF)

      I think It should be ">" instead of ">=",
      Here is a test for this:

          @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;
      }
      

      Attachments

        Activity

          People

            leojay Leo Jay
            leojay Leo Jay
            Leo Jay
            Jonathan Ellis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: