code: private void maybeRotateLog() throws IOException {
      if (!mRotateLogForNextWrite) {
        return;
      }
      if (mJournalOutputStream != null) {
        mJournalOutputStream.close();
        mJournalOutputStream = null;
      }
  
      createNewLogFile(mNextSequenceNumber);
      mRotateLogForNextWrite = false;
    }
docs: Closes the current journal output stream and creates a new one.
  The implementation must be idempotent so that it can work when retrying during failures.