code: private void updateInputStream() throws IOException {
      if (mInputStream != null && (mInputStream.mFile.isIncompleteLog() || !mInputStream.isDone())) {
        return;
      }
  
      if (mInputStream != null) {
        mInputStream.close();
        mInputStream = null;
      }
      if (mFilesToProcess.isEmpty()) {
        UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
        if (snapshot.getCheckpoints().isEmpty() && snapshot.getLogs().isEmpty()) {
          return;
        }
  
        int index = 0;
        if (!snapshot.getCheckpoints().isEmpty()) {
          UfsJournalFile checkpoint = snapshot.getLatestCheckpoint();
          if (mNextSequenceNumber < checkpoint.getEnd()) {
            String location = checkpoint.getLocation().toString();
            LOG.info("Reading checkpoint {}", location);
            mCheckpointStream = new CheckpointInputStream(
                mUfs.open(location, OpenOptions.defaults().setRecoverFailedOpen(true)));
            mNextSequenceNumber = checkpoint.getEnd();
          }
          for (; index < snapshot.getLogs().size(); index++) {
            UfsJournalFile file = snapshot.getLogs().get(index);
            if (file.getEnd() > checkpoint.getEnd()) {
              break;
            }
          }
          // index now points to the first log with mEnd > checkpoint.mEnd.
        }
        for (; index < snapshot.getLogs().size(); index++) {
          UfsJournalFile file = snapshot.getLogs().get(index);
          if ((!mReadIncompleteLog && file.isIncompleteLog())
              || mNextSequenceNumber >= file.getEnd()) {
            continue;
          }
          mFilesToProcess.add(snapshot.getLogs().get(index));
        }
      }
  
      if (!mFilesToProcess.isEmpty()) {
        mInputStream = new JournalInputStream(mFilesToProcess.poll());
      }
    }
docs: Updates the journal input stream by closing the current journal input stream if it is done and
  opening a new one.