spring-projects / spring-projects/spring-batch

MethodInvokingTaskletAdapter should store exception string in ExitStatus description [BATCH-1901]

Open
#1,695 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Eric Quilantang opened BATCH-1901 and commented

I don't see exceptions details when the tasklet fails.
I extended MethodInvokingTaskletAdapter to make them show up in spring batch admin.

/**

  • MyMethodInvokingTaskletAdapter
  • on exception, this stores exception string in {@link ExitStatus}.
  • {@link MethodInvokingTaskletAdapter} does not do this.
  • @author eric.quilantang

*/
public class JqingMethodInvokingTaskletAdapter extends MethodInvokingTaskletAdapter {

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    try {
        return super.execute(contribution, chunkContext);
    } catch (Exception e) {
        ExitStatus status = new ExitStatus(ExitStatus.FAILED.getExitCode(), e.toString());
        contribution.setExitStatus(status);
    }
    return RepeatStatus.FINISHED;
}

}


Affects: 2.1.9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at MethodInvokingTaskletAdapter and inspect its execute path, especially how a tasklet failure sets ExitStatus. Confirm that the failure status exposes the exception string in its description, and verify the behavior with the relevant existing tests or a focused test if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.