package org.warp.commonutils.concurrency.executor; import java.util.concurrent.ExecutorService; import org.jetbrains.annotations.NotNull; public class AsyncStackTraceExecutorServiceDecorator extends SimplerExecutorServiceDecorator { public AsyncStackTraceExecutorServiceDecorator(ExecutorService executorService) { super(executorService, (executor) -> { // Do nothing if it has already the asyncstacktrace executor service decorator if (executorService instanceof ExecutorServiceDecorator) { var decorators = ((ExecutorServiceDecorator) executorService).getExecutorServiceDecorators(); if (decorators.contains(AsyncStackTraceExecutorServiceDecorator.class)) { return new ExecutorDecorator(executorService) { @Override public void execute(@NotNull Runnable runnable) { super.execute(runnable); } }; } } return new AsyncStackTraceExecutorDecorator(executor); }); } }