Class TaskUtils
java.lang.Object
org.springframework.scheduling.support.TaskUtils
Utility methods for decorating tasks with error handling.
 
NOTE: This class is intended for internal use by Spring's scheduler implementations. It is only public so that it may be accessed from impl classes within other packages. It is not intended for general use.
- Since:
- 3.0
- Author:
- Mark Fisher, Juergen Hoeller
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final ErrorHandlerAn ErrorHandler strategy that will log at error level and then re-throw the Exception.static final ErrorHandlerAn ErrorHandler strategy that will log the Exception but perform no further handling.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiondecorateTaskWithErrorHandler(Runnable task, @Nullable ErrorHandler errorHandler, boolean isRepeatingTask) Decorate the task for error handling.static ErrorHandlergetDefaultErrorHandler(boolean isRepeatingTask) Return the defaultErrorHandlerimplementation based on the boolean value indicating whether the task will be repeating or not.
- 
Field Details- 
LOG_AND_SUPPRESS_ERROR_HANDLERAn ErrorHandler strategy that will log the Exception but perform no further handling. This will suppress the error so that subsequent executions of the task will not be prevented.
- 
LOG_AND_PROPAGATE_ERROR_HANDLERAn ErrorHandler strategy that will log at error level and then re-throw the Exception. Note: this will typically prevent subsequent execution of a scheduled task.
 
- 
- 
Constructor Details- 
TaskUtilspublic TaskUtils()
 
- 
- 
Method Details- 
decorateTaskWithErrorHandlerpublic static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(Runnable task, @Nullable ErrorHandler errorHandler, boolean isRepeatingTask) Decorate the task for error handling. If the providedErrorHandleris notnull, it will be used. Otherwise, repeating tasks will have errors suppressed by default whereas one-shot tasks will have errors propagated by default since those errors may be expected through the returnedFuture. In both cases, the errors will be logged.
- 
getDefaultErrorHandlerReturn the defaultErrorHandlerimplementation based on the boolean value indicating whether the task will be repeating or not. For repeating tasks it will suppress errors, but for one-time tasks it will propagate. In both cases, the error will be logged.
 
-