Uploaded image for project: 'Ratis'
  1. Ratis
  2. RATIS-471

`LogReader#readNext()` should return null or throw an error when reading off the end of the Log

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • None
    • LogService
    • None

    Description

          @Test
          public void testReadOffEndOfLog() throws Exception {
            try (LogServiceClient client = new LogServiceClient(cluster.getMetaIdentity())) {
              LogStream stream = client.createLog(LogName.of("testReadWrite"));
              LogWriter writer = stream.createWriter();
              String message = "Hello world!";
              ByteBuffer testMessage =  ByteBuffer.wrap(message.getBytes());
              writer.write(testMessage);
              LogReader reader = stream.createReader();
              ByteBuffer res = reader.readNext();
              assertEquals(message, ByteBufferUtils.toStringUtf8(res));
              // readNext() should return `null` when there is no remaining record
              res = reader.readNext();
              assertNull(res);
            }
          }
      

      The above test test should either pass (or throw an exception on the second readNext() call), but hangs indefinitely. We should be able to catch this.

      FYI vrodionov, rajeshbabu

      Attachments

        Activity

          People

            rajeshbabu Rajeshbabu Chintaguntla
            elserj Josh Elser
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: