diff --git a/spring-batch-docs/modules/ROOT/pages/domain.adoc b/spring-batch-docs/modules/ROOT/pages/domain.adoc index e999c4246..a818a35a4 100644 --- a/spring-batch-docs/modules/ROOT/pages/domain.adoc +++ b/spring-batch-docs/modules/ROOT/pages/domain.adoc @@ -534,6 +534,12 @@ As noted in the comment, `ecStep` does not equal `ecJob`. They are two different `ExecutionContexts`. The one scoped to the `Step` is saved at every commit point in the `Step`, whereas the one scoped to the Job is saved in between every `Step` execution. +NOTE: In the `ExecutionContext`, all non-transient entries must be `Serializable`. +Proper serialization of the execution context underpins the restart capability of steps and jobs. +Should you use keys or values that are not natively serializable, you are required to +employ a tailored serialization approach. Failing to serialize the execution context +may jeopardize the state persistence process, making failed jobs impossible to recover properly. + [[jobrepository]] == JobRepository diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java index 3fb0c2c4d..1c0d08ae3 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java @@ -30,8 +30,9 @@ import org.springframework.lang.Nullable; * that allows optionally for type safety on reads. It also allows for dirty checking by * setting a 'dirty' flag whenever any put is called. *
- * Note that putting null value is equivalent to removing the entry for the
- * given key.
+ * Non-transient entries should be serializable, otherwise a custom serializer should be
+ * used. Note that putting null value is equivalent to removing the entry for
+ * the given key.
*
* @author Lucas Ward
* @author Douglas Kaminsky