@Test
  public void testReadBeyondCommittedLength() throws IOException, InterruptedException {
    appendToLog("1");
    appendToLog("2");
    long size = log.getLogFileSizeIfBeingWritten(getQueue().peek()).getAsLong();
    AtomicLong fileLength = new AtomicLong(size - 1);
    try (WALEntryStream entryStream = new WALEntryStream(logQueue, fs, CONF, 0,
      p -> OptionalLong.of(fileLength.get()), new MetricsSource("1"), fakeWalGroupId)) {
      assertNotNull(next(entryStream));
      // can not get log 2
      assertEquals(HasNext.RETRY, entryStream.hasNext());
      Thread.sleep(1000);
      // still can not get log 2
      assertEquals(HasNext.RETRY, entryStream.hasNext());

      // can get log 2 now
      fileLength.set(size);
      assertNotNull(next(entryStream));

      assertEquals(HasNext.RETRY, entryStream.hasNext());
    }
  }
Tests that if we stop before hitting the end of a stream, we can continue where we left off
using the last position
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java