You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
A clear and concise description of what the bug is about.
If a job is stopped in ChunkListener#afterChunk, termainateOnly is not set.
Environment
Please provide as many details as possible: Spring Batch version, Java version, which database you use if any, etc
I assume this happens to all environments.
Steps to reproduce
Steps to reproduce the issue.
JobOperator#stop in ChunkListener#afterChunk then it will still run the next chunk.
Expected behavior
A clear and concise description of what you expected to happen.
The next chunk shouldn't run.
Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.
The text was updated successfully, but these errors were encountered:
Thank you for opening this issue. However, I think there is misuse of the APIs according to the description you gave:
Bug description: If a job is stopped in ChunkListener#afterChunk, termainateOnly is not set.
Steps to reproduce: JobOperator#stop in ChunkListener#afterChunk then it will still run the next chunk.
JobOperator#stop is designed to stop a job from the outside (a separate thread or process), while StepExecution#setTerminateOnly() is designed to stop a job from within the inside.
So if you want to stop a step after a given chunk, you need to set the terminateOnly flag on the step execution and not call JobOperator#stop. Here is a hypothetical example of a chunk listener that should stop the execution if the number of chunks exceeds a given limit:
importorg.springframework.batch.core.ChunkListener;
importorg.springframework.batch.core.launch.JobOperator;
importorg.springframework.batch.core.scope.context.ChunkContext;
publicclassMyChunkListenerimplementsChunkListener {
// private JobOperator jobOperator;privateintmaxChunks;
// constructor omitted@OverridepublicvoidafterChunk(ChunkContextcontext) {
if (++maxChunks > 10) {
// jobOperator.stop(context.getStepContext().getStepExecution().getJobExecutionId()); // this is incorrect context.getStepContext().getStepExecution().setTerminateOnly();
}
}
}
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
A clear and concise description of what the bug is about.
If a job is stopped in ChunkListener#afterChunk,
termainateOnly
is not set.Environment
Please provide as many details as possible: Spring Batch version, Java version, which database you use if any, etc
I assume this happens to all environments.
Steps to reproduce
Steps to reproduce the issue.
JobOperator#stop in ChunkListener#afterChunk then it will still run the next chunk.
Expected behavior
A clear and concise description of what you expected to happen.
The next chunk shouldn't run.
Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.
The text was updated successfully, but these errors were encountered: