protected void checkBeforeOffer(final E event) {
    if (isClosed.get() && event instanceof EnrichedEvent) {
      ((EnrichedEvent) event).clearReferenceCount(BlockingPendingQueue.class.getName());
    }
  }
DO NOT FORGET to set eventCounter to new value after invoking this method.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/agent/task/connection/BlockingPendingQueue.java