Description
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
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)