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

JobParameters should use LinkedHashMap instead of HashMap #4179

Closed
JinseongHwang opened this issue Aug 23, 2022 · 0 comments
Closed

JobParameters should use LinkedHashMap instead of HashMap #4179

JinseongHwang opened this issue Aug 23, 2022 · 0 comments

Comments

@JinseongHwang
Copy link

from Stackoverflow

Hi there,

Compared to HashMap, LinkedHashMap guarantees input order.

In Spring Batch, I think HashMap is enough to save JobParameter, but I don't know why JobParameters used LinkedHashMap. What do you think about this?

Below are some of the implementations of JobParameters. Github Link

public class JobParameters implements Serializable {

    private final Map<String,JobParameter> parameters;

    public JobParameters() {
        this.parameters = new LinkedHashMap<>();
    }

    public JobParameters(Map<String,JobParameter> parameters) {
        this.parameters = new LinkedHashMap<>(parameters);
    }

    // ...
}

From what I've looked for, LinkedHashMap is more faster than HashMap in some features. ref
Have you decided to use LinkedHashMap simply for the above reasons?

I think, It seems good to use HashMap if ordering is not needed.
Using LinkedHashMap seems to have something to do with the order. It can cause misunderstanding.

What do you think about this?

Thanks.

@JinseongHwang JinseongHwang added the status: waiting-for-triage Issues that we did not analyse yet label Aug 23, 2022
@fmbenhassine fmbenhassine added in: core type: enhancement and removed status: waiting-for-triage Issues that we did not analyse yet labels Oct 24, 2022
@fmbenhassine fmbenhassine added this to the 5.0.2 milestone Mar 21, 2023
@fmbenhassine fmbenhassine changed the title Why Spring batch JobParameters using LinkedHashMap JobParameters should use LinkedHashMap instead of HashMap May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants