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

JobExecution getJobExecution(@Nullable Long executionId) return null when using MongoDB as JobExplorer #4722

Closed
weiz-cn opened this issue Nov 29, 2024 · 1 comment

Comments

@weiz-cn
Copy link

weiz-cn commented Nov 29, 2024

Please do a quick search on Github issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
JobExecution getJobExecution(@nullable Long executionId) return null when use MongoDB as JobExplorer

Environment
Java 17, Spring Batch 5.2, MongoDB 4.4.15-15

Steps to reproduce
Steps to reproduce the issue.

Expected behavior
The method should return JobExecution

Minimal Complete Reproducible example
The issue is caused by

org.springframework.batch.core.repository.persistence.JobExecution jobExecution = this.mongoOperations.findById(

From my MongoDB, BATCH_JOB_EXECUTION collection, I saw:

  {
    _id: ObjectId('67486c0b30339b645f463079'),
    jobExecutionId: Long('4'),
    jobInstanceId: Long('4'),

The input argument is the executionId (4), not id (67486c0b30339b645f463079) in MongoDB, the code above use "this.mongoOperations.findById" to find, then nothing is found.
The code should be changed to something like:

Query query = query(where("jobExecutionId").is(executionId);
this.mongoOperations.findOne(query, org.springframework.batch.core.repository.persistence.JobExecution.class,
				JOB_EXECUTIONS_COLLECTION_NAME)
@weiz-cn weiz-cn added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Nov 29, 2024
@weiz-cn weiz-cn changed the title JobExecution getJobExecution(@Nullable Long executionId) return null when use MongoDB as JobExplorer JobExecution getJobExecution(@Nullable Long executionId) return null when using MongoDB as JobExplorer Nov 29, 2024
@fmbenhassine fmbenhassine added in: core and removed status: waiting-for-triage Issues that we did not analyse yet labels Dec 6, 2024
@fmbenhassine fmbenhassine added this to the 5.2.1 milestone Dec 6, 2024
@fmbenhassine
Copy link
Contributor

This is a valid issue, thank you for reporting it! Resolved with #4724 .

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