docs: private MetadataResult applyMetadata(Indexed<MetadataEntry> entry) {
      // If the session ID is non-zero, read the metadata for the associated state machine.
      if (entry.entry().session() > 0) {
        RaftSession session = raft.getSessions().getSession(entry.entry().session());
  
        // If the session is null, return an UnknownSessionException.
        if (session == null) {
          logger.warn("Unknown session: " + entry.entry().session());
          throw new RaftException.UnknownSession("Unknown session: " + entry.entry().session());
        }
  
        Set<SessionMetadata> sessions = new HashSet<>();
        for (RaftSession s : raft.getSessions().getSessions()) {
          if (s.primitiveName().equals(session.primitiveName())) {
            sessions.add(new SessionMetadata(s.sessionId().id(), s.primitiveName(), s.primitiveType().name()));
          }
        }
        return new MetadataResult(sessions);
      } else {
        Set<SessionMetadata> sessions = new HashSet<>();
        for (RaftSession session : raft.getSessions().getSessions()) {
          sessions.add(new SessionMetadata(session.sessionId().id(), session.primitiveName(), session.primitiveType().name()));
        }
        return new MetadataResult(sessions);
      }
    }