Skip to content

BATCH-2783: Change getUniqueJobParameters() to have a lower chance of repeating #3701

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
wants to merge 2 commits into from

Conversation

saikatbhadra
Copy link
Contributor

@saikatbhadra saikatbhadra commented Apr 26, 2020

Background

We noticed that integration tests for a batch job (with many tests) were failing intermittently. After debugging, I found that JobLauncherTestUtils.launchJob was occasionally relaunching the same job instance. After looking at the code, I saw that a random number generator was being used which does not guarantee that the number generate would be unique. I believe a UUID would be more appropriate as strongly guarantees that an ID does not repeat (except in highly exceptional cases). This change strongly assures that the JobParameter is unique every time getUniqueJobParameters() is called.

@saikatbhadra
Copy link
Contributor Author

cc @mminella @benas

@saikatbhadra saikatbhadra changed the title Change getUniqueJobParameters() to have a lower chance of repeating BATCH-2783: Change getUniqueJobParameters() to have a lower chance of repeating Apr 26, 2020
@mminella mminella self-assigned this Apr 27, 2020
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we restore the explicit imports? Spring's coding standards prefers to avoid .* imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed

@fmbenhassine fmbenhassine added this to the 4.3.0 milestone Apr 30, 2020
@fmbenhassine fmbenhassine added has: backports Legacy label from JIRA. Superseded by "for: backport-to-x.x.x" in: test pr-for: bug labels Apr 30, 2020
@fmbenhassine
Copy link
Contributor

LGTM. Rebased, squashed and merged as 670b640. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: backports Legacy label from JIRA. Superseded by "for: backport-to-x.x.x" in: test pr-for: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants