Skip to content

Commit 3796ac6

Browse files
hwan33fmbenhassine
authored andcommitted
Update documentation about serializable keys in the execution context
Resolves #4457 (cherry picked from commit dcd1ac8)
1 parent 75054b5 commit 3796ac6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

spring-batch-docs/asciidoc/domain.adoc

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

559+
NOTE: In the `ExecutionContext`, all non-transient entries must be `Serializable`.
560+
Proper serialization of the execution context underpins the restart capability of steps and jobs.
561+
Should you use keys or values that are not natively serializable, you are required to
562+
employ a tailored serialization approach. Failing to serialize the execution context
563+
may jeopardize the state persistence process, making failed jobs impossible to recover properly.
564+
559565
=== JobRepository
560566

561567
`JobRepository` is the persistence mechanism for all of the Stereotypes mentioned above.

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,8 +29,10 @@
2929
* for a map that allows optionally for type safety on reads. It also allows for
3030
* dirty checking by setting a 'dirty' flag whenever any put is called.
3131
*
32-
* Note that putting <code>null</code> value is equivalent to removing the entry
33-
* for the given key.
32+
* Non-transient entries should be serializable, otherwise a custom serializer should be
33+
* used. Note that putting <code>null</code> value is equivalent to removing the entry
34+
* for
35+
* the given key.
3436
*
3537
* @author Lucas Ward
3638
* @author Douglas Kaminsky

0 commit comments

Comments
 (0)