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
Nested ClassesModifier and TypeClassDescriptionstatic classWraps the runtimeRejectedExecutionException.static classVersion ofRejectedExecutionException, which treats the error as fatal. -
Method Summary
Modifier and TypeMethodDescriptionstatic RejectedExecutionExceptionCreates a runtimeRejectedExecutionExceptionforExecutorServiceUtils.ExecutionRejectedException.static voidsubmitAsync(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 runtimeRejectedExecutionExceptionforExecutorServiceUtils.ExecutionRejectedException. This version takes theExecutorServiceUtils.ExecutionRejectedException.isFatal()value into account and createsExecutorServiceUtils.FatalRejectedExecutionExceptionif required.- Parameters:
message- Messagecause- Base non-Runtime exception- Returns:
- Created Runtime exception
-