Package org.jenkinsci.remoting.util
Class ExecutorServiceUtils
java.lang.Object
org.jenkinsci.remoting.util.ExecutorServiceUtils
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class ExecutorServiceUtils
extends Object
Helper class for
ExecutorService
operations.- Author:
- Oleg Nenashev
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Wraps the runtimeRejectedExecutionException
.static class
Version ofRejectedExecutionException
, which treats the error as fatal. -
Method Summary
Modifier and TypeMethodDescriptionstatic RejectedExecutionException
Creates a runtimeRejectedExecutionException
forExecutorServiceUtils.ExecutionRejectedException
.static void
submitAsync
(ExecutorService es, Runnable runnable) Submits a task to the executor service without further handling.
-
Method Details
-
submitAsync
public static void submitAsync(@NonNull ExecutorService es, @NonNull Runnable runnable) throws ExecutorServiceUtils.ExecutionRejectedException Submits a task to the executor service without further handling. The originalExecutorService.submit(Runnable)
method actually expects this return value to be handled, but this method explicitly relies on the external logic to handle the future operation. Use on your own risk.- Parameters:
es
- Executor servicerunnable
- Operation to be executed- Throws:
ExecutorServiceUtils.ExecutionRejectedException
- Execution is rejected by the executor service
-
createRuntimeException
@NonNull public static RejectedExecutionException createRuntimeException(@NonNull String message, @NonNull ExecutorServiceUtils.ExecutionRejectedException cause) Creates a runtimeRejectedExecutionException
forExecutorServiceUtils.ExecutionRejectedException
. This version takes theExecutorServiceUtils.ExecutionRejectedException.isFatal()
value into account and createsExecutorServiceUtils.FatalRejectedExecutionException
if required.- Parameters:
message
- Messagecause
- Base non-Runtime exception- Returns:
- Created Runtime exception
-