Ejemplo n.º 1
0
 @Override
 public void run() {
   try {
     runnable.run();
   } catch (Exception e) {
     logger.warn("failed to run {}", e, runnable.toString());
   }
 }
Ejemplo n.º 2
0
  @Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    if (r instanceof RunnableScheduledFuture) {
      Object callable = ReflectionUtil.getFieldValue(r, "callable");
      Object cfAsync = ReflectionUtil.getFieldValue(callable, "task");
      r = (Runnable) cfAsync;
    }

    if (r instanceof ForkJoinTask && r.toString().contains("CompletableFuture$Async")) {
      Field field = ReflectionUtil.getField(r, "dst"); // jdk8u20
      if (field == null) {
        field = ReflectionUtil.getField(r, "dep"); // jdk8u40
      }
      Object dst = ReflectionUtil.getFieldValue(r, field);
      if (dst instanceof CompletableFuture) {
        ((CompletableFuture) dst).cancel(false);
        log.debug("Canceled completable future {}", r);
      }
    } else if (r instanceof Future) {
      ((Future) r).cancel(false);
      log.debug("Canceled future {}", r);
    }
  }
Ejemplo n.º 3
0
 public String toString() {
   return task.toString();
 }
Ejemplo n.º 4
0
 @Override
 public String toString() {
   return "[threaded] " + runnable.toString();
 }
Ejemplo n.º 5
0
 @Override
 public String toString() {
   Runnable task = myTask;
   return super.toString() + (task != null ? task.toString() : null);
 }