Skip to content

Use the Chunk API consistently Β #3954

Closed

Description

@fmbenhassine

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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions