Skip to content

Consider making JobParameters#getParameters() immutable #3980

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

Closed
marschall opened this issue Aug 23, 2021 · 0 comments
Closed

Consider making JobParameters#getParameters() immutable #3980

marschall opened this issue Aug 23, 2021 · 0 comments
Labels
for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line in: core type: bug
Milestone

Comments

@marschall
Copy link
Contributor

JobParameters#getParameters() currently returns a mutable defensive copy of the job parameters, even though the Javadoc says

@return an unmodifiable map containing all parameters.

This means that anybody who just wants read-only access to the job parameters, eg. only to iterate over them, eg. SimpleJobRepository#createJobExecution has to incur the cost of a defensive copy of a LinkedHashMap. Copying a LinkedHashMap is unfortunately quite expensive in term of memory allocation.

It looks like to copy was made modifiable with BATCH-671 / #2905 / e68a413

@marschall marschall added the status: waiting-for-triage Issues that we did not analyse yet label Aug 23, 2021
@fmbenhassine fmbenhassine added for: backport-to-4.2.x Issues that will be back-ported to the 4.2.x line in: core type: bug and removed status: waiting-for-triage Issues that we did not analyse yet labels Aug 24, 2021
@fmbenhassine fmbenhassine added this to the 4.3.4 milestone Aug 24, 2021
marschall added a commit to marschall/spring-batch that referenced this issue Sep 1, 2021
Make  JobParameters#getParameters() immutable and avoid the defensive
copy.

Fixes spring-projects#3980
@fmbenhassine fmbenhassine linked a pull request Sep 1, 2021 that will close this issue
fmbenhassine pushed a commit that referenced this issue Oct 1, 2021
Make  JobParameters#getParameters() immutable and avoid the defensive
copy.

Fixes #3980
fmbenhassine pushed a commit to fmbenhassine/spring-batch that referenced this issue Oct 1, 2021
Make  JobParameters#getParameters() immutable and avoid the defensive
copy.

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

Successfully merging a pull request may close this issue.

2 participants