-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
SystemCommandTasklet does not propagate errors #4483
Comments
Hi team, I want to work for this issue. Can I? |
@hyosyung Sure! Thank you for your offer to help. Contributions are welcome! |
@hyosyung Have you managed to work on this issue? I think the way to address this is to throw an exception if the exit code mapper maps the exit code to a failed status, something like: if (systemCommandTask.isDone()) {
- contribution.setExitStatus(systemProcessExitCodeMapper.getExitStatus(systemCommandTask.get()));
- return RepeatStatus.FINISHED;
+ Integer exitCode = systemCommandTask.get();
+ ExitStatus exitStatus = systemProcessExitCodeMapper.getExitStatus(exitCode);
+ if (ExitStatus.FAILED.equals(exitStatus)) {
+ throw new SystemCommandException("Execution of system command failed with exit code " + exitCode);
+ }
+ else {
+ contribution.setExitStatus(exitStatus);
+ return RepeatStatus.FINISHED;
+ }
} This way, the step will be marked as failed correctly. Wdyt? Please let me know if you can contribute a PR along these lines, otherwise I will take care of the fix. Thank you upfront. |
Hi @fmbenhassine , based on your suggestion I create fix PR #4566 PTAL :) Thank you for detailed guide! |
SystemCommandTasklet
does not propagate errorsIf a command executed by
SystemCommandTasklet
returns a non zero exit code, the system exit code is mapped to ExitStatus.FAILED. However, the overall step execution status is BatchStatus.COMPLETED, meaning the step (and the job) is completed successfully.Environment
spring-batch 5.0.3
Steps to reproduce
Create a Job with a
SystemCommandTasklet
where the system command executed will return a non zero exit code.Expected behavior
The error should be propagated to the Step, and ultimately to the overall Job execution status.
The text was updated successfully, but these errors were encountered: