private long closeFailureBatchHandler()

in src/main/java/com/aliyun/openservices/aliyun/log/producer/LogProducer.java [537:556]


  private long closeFailureBatchHandler(long timeoutMs)
      throws InterruptedException, ProducerException {
    long startMs = System.currentTimeMillis();
    failureBatchHandler.close();
    boolean invokedFromCallback =
        Thread.currentThread() == this.successBatchHandler
            || Thread.currentThread() == this.failureBatchHandler;
    if (invokedFromCallback) {
      LOGGER.warn(
          "Skip join failure batch handler since you have incorrectly invoked close from the producer call-back");
      return timeoutMs;
    }
    failureBatchHandler.join(timeoutMs);
    if (failureBatchHandler.isAlive()) {
      LOGGER.warn("The failure batch handler thread is still alive");
      throw new ProducerException("the failure batch handler thread is still alive");
    }
    long nowMs = System.currentTimeMillis();
    return Math.max(0, timeoutMs - nowMs + startMs);
  }