code: @Override
      public void sendEvents(TreeSet<Event> events) {
          if (events == null) {
              throw new IllegalArgumentException("Events must be not null");
          }
          if (events.isEmpty()) {
              return;
          }
  
          addEvents(events);
  
          if (distributed) {
              partitionManager.notifyEvents(new ArrayList<>(events));
          }
      }
docs: use synchronized blocks to protect pendingEvents.