Implement `InterceptingExecutorService` without Guava
package jenkins.util;
-import com.google.common.util.concurrent.ForwardingExecutorService;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -18,7 +16,7 @@ import java.util.concurrent.TimeoutException;
* @author Kohsuke Kawaguchi
* @since 1.557
*/
-public abstract class InterceptingExecutorService extends ForwardingExecutorService {
+public abstract class InterceptingExecutorService implements ExecutorService {
private final ExecutorService base;
public InterceptingExecutorService(ExecutorService base) {
@@ -29,49 +27,78 @@ public abstract class InterceptingExecutorService extends ForwardingExecutorServ
protected abstract <V> Callable<V> wrap(Callable<V> r);
- @Override
protected ExecutorService delegate() {
return base;
}
- @Override
public <T> Future<T> submit(Callable<T> task) {
- return super.submit(wrap(task));
+ return delegate().submit(wrap(task));
}
@Override
public <T> Future<T> submit(Runnable task, T result) {
- return super.submit(wrap(task), result);
+ return delegate().submit(wrap(task), result);
}
@Override
public Future<?> submit(Runnable task) {
- return super.submit(wrap(task));
+ return delegate().submit(wrap(task));
}
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
- return super.invokeAll(wrap(tasks));
+ return delegate().invokeAll(wrap(tasks));
}
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
- return super.invokeAll(wrap(tasks), timeout, unit);
+ return delegate().invokeAll(wrap(tasks), timeout, unit);
}
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
- return super.invokeAny(wrap(tasks));
+ return delegate().invokeAny(wrap(tasks));
}
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
- return super.invokeAny(wrap(tasks), timeout, unit);
+ return delegate().invokeAny(wrap(tasks), timeout, unit);
}
@Override
public void execute(Runnable command) {
- super.execute(wrap(command));
+ delegate().execute(wrap(command));
+ }
+
+
+ @Override
+ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
+ return delegate().awaitTermination(timeout, unit);
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return delegate().isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return delegate().isTerminated();
+ }
+
+ @Override
+ public void shutdown() {
+ delegate().shutdown();
+ }
+
+ @Override
+ public List<Runnable> shutdownNow() {
+ return delegate().shutdownNow();
+ }
+
+ @Override
+ public String toString() {
+ return delegate().toString();
}
private <T> Collection<Callable<T>> wrap(Collection<? extends Callable<T>> callables) {
