docs: @SuppressWarnings("unchecked")
    private RaftServiceContext initializeService(PrimitiveId primitiveId, PrimitiveType primitiveType, String serviceName, byte[] config) {
      RaftServiceContext oldService = raft.getServices().getService(serviceName);
      ServiceConfig serviceConfig = config == null ? new ServiceConfig() : Serializer.using(primitiveType.namespace()).decode(config);
      RaftServiceContext service = new RaftServiceContext(
          primitiveId,
          serviceName,
          primitiveType,
          serviceConfig,
          primitiveType.newService(serviceConfig),
          raft,
          threadContextFactory);
      raft.getServices().registerService(service);
  
      // If a service with this name was already registered, remove all of its sessions.
      if (oldService != null) {
        raft.getSessions().removeSessions(oldService.serviceId());
      }
      return service;
    }