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

Consider removing ChunkContext from Tasklet#execute method #4687

Open
fmbenhassine opened this issue Oct 23, 2024 · 0 comments
Open

Consider removing ChunkContext from Tasklet#execute method #4687

fmbenhassine opened this issue Oct 23, 2024 · 0 comments

Comments

@fmbenhassine
Copy link
Contributor

A tasklet is not necessarily chunk-oriented, so having a ChunkContext as a parameter in Tasklet#execute feels strange (if not wrong) to me:

@FunctionalInterface
public interface Tasklet {

	/**
	 * Given the current context in the form of a step contribution, do whatever is
	 * necessary to process this unit inside a transaction. Implementations return
	 * {@link RepeatStatus#FINISHED} if finished. If not they return
	 * {@link RepeatStatus#CONTINUABLE}. On failure throws an exception.
	 * @param contribution mutable state to be passed back to update the current step
	 * execution
	 * @param chunkContext attributes shared between invocations but not between restarts
	 * @return an {@link RepeatStatus} indicating whether processing is continuable.
	 * Returning {@code null} is interpreted as {@link RepeatStatus#FINISHED}
	 * @throws Exception thrown if error occurs during execution.
	 */
	@Nullable
	RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception;

}

The chunk context is documented to hold attributes shared between invocations but not between restarts, but is this really required? This actually violates the ISP for people not using this functionality (ie the parameter won't be used).

If considered, this would be a big breaking change, but it is worth fixing in a major release for a cleaner API design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant