code: private static int readLogVersion(DataInputStream in) throws IOException {
      int logVersion = 0;
      in.mark(4);
      // See comments in EditLogFileInputStream as to why readLogVersion is
      // implemented in this way
      boolean available = true;
      try {
        logVersion = in.readByte();
      } catch (EOFException e) {
        available = false;
      }
  
      if (available) {
        in.reset();
        logVersion = in.readInt();
        if (logVersion < FSConstants.LAYOUT_VERSION) {
          throw new LedgerHeaderCorruptException(
              "Unexpected version of the log segment in the ledger: " + logVersion +
                  ". Current version is " + FSConstants.LAYOUT_VERSION + ".");
        }
      }
      return logVersion;
    }
docs: Safely reads the log version from the stream. Logic is exactly the same
  as in the equivalent {@link EditLogFileInputStream} method.
  @see EditLogFileInputStream#readLogVersion(DataInputStream)
  @return The log version or 0 if stream is empty