Top Description Inners Fields Constructors Methods
org.springframework.scheduling.support

public abstract Class TaskUtils

extends Object
Class Inheritance
Imports
java.util.concurrent.Future, org.apache.commons.logging.Log, .LogFactory, org.springframework.lang.Nullable, org.springframework.util.ErrorHandler, .ReflectionUtils

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.

Authors
Mark Fisher, Juergen Hoeller
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TaskUtils.LoggingErrorHandler

An ErrorHandler implementation that logs the Throwable at error level.

private static class
TaskUtils.PropagatingErrorHandler

An ErrorHandler implementation that logs the Throwable at error level and then propagates it.

Field Summary

Modifier and TypeField and Description
public static final ErrorHandler
LOG_AND_PROPAGATE_ERROR_HANDLER

An ErrorHandler strategy that will log at error level and then re-throw the Exception.

public static final ErrorHandler
LOG_AND_SUPPRESS_ERROR_HANDLER

An ErrorHandler strategy that will log the Exception but perform no further handling.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static DelegatingErrorHandlingRunnable
decorateTaskWithErrorHandler(Runnable task, ErrorHandler errorHandler, boolean isRepeatingTask)

Decorate the task for error handling.

public static ErrorHandler
getDefaultErrorHandler(boolean isRepeatingTask)

Return the default ErrorHandler implementation based on the boolean value indicating whether the task will be repeating or not.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOG_AND_PROPAGATE_ERROR_HANDLERback to summary
public static final ErrorHandler LOG_AND_PROPAGATE_ERROR_HANDLER

An 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.

LOG_AND_SUPPRESS_ERROR_HANDLERback to summary
public static final ErrorHandler LOG_AND_SUPPRESS_ERROR_HANDLER

An 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.

Constructor Detail

TaskUtilsback to summary
public TaskUtils()

Method Detail

decorateTaskWithErrorHandlerback to summary
public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(Runnable task, ErrorHandler errorHandler, boolean isRepeatingTask)

Decorate the task for error handling. If the provided ErrorHandler is not null, 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 returned Future. In both cases, the errors will be logged.

getDefaultErrorHandlerback to summary
public static ErrorHandler getDefaultErrorHandler(boolean isRepeatingTask)

Return the default ErrorHandler implementation 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.

org.springframework.scheduling.support back to summary

private Class TaskUtils.LoggingErrorHandler

extends Object
implements ErrorHandler
Class Inheritance
  • java.lang.Object
  • org.springframework.scheduling.support.TaskUtils.LoggingErrorHandler
All Implemented Interfaces
org.springframework.util.ErrorHandler
Known Direct Subclasses
org.springframework.scheduling.support.TaskUtils.PropagatingErrorHandler

An ErrorHandler implementation that logs the Throwable at error level. It does not perform any additional error handling. This can be useful when suppression of errors is the intended behavior.

Field Summary

Modifier and TypeField and Description
private final Log

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handleError(Throwable t)

Implements org.springframework.util.ErrorHandler.handleError.

Handle the given error, possibly rethrowing it as a fatal exception.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
private final Log logger

Constructor Detail

LoggingErrorHandlerback to summary
private LoggingErrorHandler()

Method Detail

handleErrorback to summary
public void handleError(Throwable t)

Implements org.springframework.util.ErrorHandler.handleError.

Doc from org.springframework.util.ErrorHandler.handleError.

Handle the given error, possibly rethrowing it as a fatal exception.

Annotations
@Override
org.springframework.scheduling.support back to summary

private Class TaskUtils.PropagatingErrorHandler

extends LoggingErrorHandler
Class Inheritance

An ErrorHandler implementation that logs the Throwable at error level and then propagates it.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void

Constructor Detail

PropagatingErrorHandlerback to summary
private PropagatingErrorHandler()

Method Detail

handleErrorback to summary
public void handleError(Throwable t)

Overrides org.springframework.scheduling.support.TaskUtils.LoggingErrorHandler.handleError.

Implements org.springframework.util.ErrorHandler.handleError.

Doc from org.springframework.util.ErrorHandler.handleError.

Handle the given error, possibly rethrowing it as a fatal exception.

Annotations
@Override