Skip to content

Commit dcd1ac8

Browse files
hwan33fmbenhassine
authored andcommitted
Update documentation about serializable keys in the execution context
Resolves #4457
1 parent 41f0fc8 commit dcd1ac8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

spring-batch-docs/modules/ROOT/pages/domain.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ As noted in the comment, `ecStep` does not equal `ecJob`. They are two different
534534
`ExecutionContexts`. The one scoped to the `Step` is saved at every commit point in the
535535
`Step`, whereas the one scoped to the Job is saved in between every `Step` execution.
536536

537+
NOTE: In the `ExecutionContext`, all non-transient entries must be `Serializable`.
538+
Proper serialization of the execution context underpins the restart capability of steps and jobs.
539+
Should you use keys or values that are not natively serializable, you are required to
540+
employ a tailored serialization approach. Failing to serialize the execution context
541+
may jeopardize the state persistence process, making failed jobs impossible to recover properly.
542+
537543
[[jobrepository]]
538544
== JobRepository
539545

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/ExecutionContext.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
* that allows optionally for type safety on reads. It also allows for dirty checking by
3131
* setting a 'dirty' flag whenever any put is called.
3232
* <p>
33-
* Note that putting <code>null</code> value is equivalent to removing the entry for the
34-
* given key.
33+
* Non-transient entries should be serializable, otherwise a custom serializer should be
34+
* used. Note that putting <code>null</code> value is equivalent to removing the entry for
35+
* the given key.
3536
*
3637
* @author Lucas Ward
3738
* @author Douglas Kaminsky

0 commit comments

Comments
 (0)