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

Use the Chunk API consistently #3954

Closed
fmbenhassine opened this issue Jun 29, 2021 · 0 comments
Closed

Use the Chunk API consistently #3954

fmbenhassine opened this issue Jun 29, 2021 · 0 comments

Comments

@fmbenhassine
Copy link
Contributor

fmbenhassine commented Jun 29, 2021

A chunk of items is a key concept in the chunk-oriented processing model and is nicely modelled with the org.springframework.batch.core.step.item.Chunk API. This API is used in almost all interfaces/classes related to the implementation of this model (ie ChunkProvider, ChunkProcessor, etc) except for the ItemWriter<T> where a List<? extends T> is used instead. I believe Chunk<T> is a better encapsulation for the chunk of items than a List<? extends T>:

public interface ItemWriter<T> {
	
-- void write(List<? extends T> items) throws Exception;
++ void write(Chunk<? extends T> items) throws Exception;

}

This would make the ItemWriter API more coherent and consistent with the rest of the package. This is obviously a breaking change and requires moving the Chunk API to the infrastructure module, so it is a good candidate for v5 in my opinion.

NB: This should not be an issue for the JSR-352 implementation (which is deprecated anyway) as there is already an adapter for the item writer: org.springframework.batch.jsr.item.ItemWriterAdapter. This adapter can be updated to adapt a Chunk<T> to a List<Object> as expected by the JSR.

In the spring-batch-integration module, ChunkRequest could also be updated to use Chunk<T> instead of Collection<? extends T> for consistency.

@fmbenhassine fmbenhassine added this to the 5.0.0 milestone Jun 29, 2021
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Aug 4, 2022
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Aug 5, 2022
fmbenhassine added a commit to fmbenhassine/spring-batch that referenced this issue Aug 5, 2022
@fmbenhassine fmbenhassine modified the milestones: 5.0.0, 5.0.0-M5 Aug 19, 2022
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