Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultJobParametersExtractor no longer copies keys from JobParameters when not contained in ExecutionContext #4458

Closed
jwillebrands opened this issue Oct 3, 2023 · 1 comment
Labels
for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line in: core type: bug
Milestone

Comments

@jwillebrands
Copy link
Contributor

jwillebrands commented Oct 3, 2023

Bug description
In Spring Batch 4.x DefaultJobParametersExtractor used to copy its configured keys from JobParameters when not contained in the ExecutionContext. In 5.x, this broke. It will now only consider JobParameters keys when useAllParentParameters is set to true. In that case it will copy JobParameters indiscriminately.

Judging by the javadoc and parameter names, I reckon this is a bug and behavior should be reverted to its 4.x behavior.

Environment
Spring Batch 5.0.3 and also present in main branch.

Steps to reproduce

  1. Use a DefaultJobParametersExtractor with useAllParentParameters = false and keys = ["jobParamKey"]
  2. Run getJobParameters for an ExecutionContext without jobParamKey set, and with parent JobParameters containing a value for jobParamKey
  3. Observe that the created JobParameters does not have a value for jobParamKey

Expected behavior
I expected same behavior as in 4.x: jobParamKey propagated to new JobParameters.

Minimal Complete Reproducible example
I will attach create a MR containing test case shortly.

@fmbenhassine
Copy link
Contributor

That's a valid regression. Thank you for raising it and for opening a PR! I will plan the fix for the next release.

@fmbenhassine fmbenhassine added in: core for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line and removed status: waiting-for-triage Issues that we did not analyse yet labels Oct 13, 2023
@fmbenhassine fmbenhassine added this to the 5.1.0 milestone Oct 13, 2023
fmbenhassine pushed a commit that referenced this issue Oct 18, 2023
Fix DefaultJobParametersExtractor to copy values from JobParameters when
they are missing from ExecutionContext. Javadoc states this class is
supposed to do just that, but seems to have broken in the 5.x API revamp.

Resolves #4458

(cherry picked from commit b2a287d)
@fmbenhassine fmbenhassine modified the milestones: 5.1.0, 5.1.0-RC1 Oct 18, 2023
fmbenhassine pushed a commit to fmbenhassine/spring-batch that referenced this issue Oct 23, 2023
Fix DefaultJobParametersExtractor to copy values from JobParameters when
they are missing from ExecutionContext. Javadoc states this class is
supposed to do just that, but seems to have broken in the 5.x API revamp.

Resolves spring-projects#4458
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: backport-to-5.0.x Issues that will be back-ported to the 5.0.x line in: core type: bug
Projects
None yet
2 participants