/** * Submits a task to the executor service without further handling. * The original {@link ExecutorService#submit(java.lang.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. * @param es Executor service * @param runnable Operation to be executed * @throws ExecutionRejectedException Execution is rejected by the executor service */ @Nonnull @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE", justification = "User of this API explicitly submits the task in the async mode on his own risk") public static void submitAsync(@Nonnull ExecutorService es, @Nonnull Runnable runnable) throws ExecutionRejectedException { try { es.submit(runnable); } catch (RejectedExecutionException ex) { // Rethrow and make API users handle this. throw new ExecutionRejectedException(runnable, es, ex); } }
/** * Creates a runtime {@link RejectedExecutionException} for {@link ExecutionRejectedException}. * This version takes the {@link ExecutionRejectedException#isFatal()} value into account * and creates {@link FatalRejectedExecutionException} if required. * @param message Message * @param cause Base non-Runtime exception * @return Created Runtime exception */ @Nonnull public static RejectedExecutionException createRuntimeException( @Nonnull String message, @Nonnull ExecutionRejectedException cause) { if (cause.isFatal()) { return new FatalRejectedExecutionException(message, cause); } else { return new RejectedExecutionException(message, cause); } }
LOGGER.log(Level.SEVERE, message, ex); if (ex.isFatal()) {
ex.getExecutorServiceDisplayName(), ex.getRunnableDisplayName()), ex); throw ExecutorServiceUtils.createRuntimeException("Base executor service has rejected the task from the queue", ex);