diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunk.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunk.java index a87a44d55..d0d4c11c9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunk.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunk.java @@ -17,15 +17,18 @@ package org.springframework.batch.core.domain; import java.io.Serializable; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import org.springframework.util.Assert; - /** - * A 'chunk' of items, that will be committed together. It is expected that a + *
A 'chunk' of items, that will be committed together. It is expected that a * chunk may be serialized, especially if using a queue to dispatch chunks to - * various {@link ChunkProcessor}s. + * various {@link ChunkProcessor}s.
+ * + *A note on serialization: A chunk is only as serializable as as the items + * it contains, and no validation is performed to ensure they are serialiable. + * Therefore, it is expected that constructors of this class will ensure this + * condition if they intend to use the chunk in such a way that will require + * serialization.
* * @author Ben Hale * @author Lucas Ward @@ -37,7 +40,6 @@ public class Chunk implements Serializable { private final List items; public Chunk(Long id, List items) { - validateSerializable(items); this.items = items; this.id = id; } @@ -59,15 +61,4 @@ public class Chunk implements Serializable { public Long getId() { return id; } - - /** - * In order for the whole chunk to be serializable, every item in the chunk - * must be serializable. - */ - private void validateSerializable(List items) { - for (Iterator i = items.iterator(); i.hasNext();) { - Assert.isInstanceOf(Serializable.class, i.next(), "All items in a chunk must be serialiable"); - } - } - } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java index f95199254..f003b8400 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Chunker.java @@ -16,6 +16,7 @@ package org.springframework.batch.core.domain; import org.springframework.batch.io.exception.ReadFailureException; +import org.springframework.batch.item.ItemStream; /** @@ -26,7 +27,7 @@ import org.springframework.batch.io.exception.ReadFailureException; * @author Ben Hale * @author Lucas Ward */ -public interface Chunker { +public interface Chunker extends ItemStream { /** * Read in a chunk, given the provided chunk size for the given StepExecution. diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java index b03fc865f..cb93f3f07 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/domain/Dechunker.java @@ -16,6 +16,7 @@ package org.springframework.batch.core.domain; import org.springframework.batch.item.ItemReader; +import org.springframework.batch.item.ItemStream; /** * Interface defining the contract for dechunking a {@link Chunk}. Similar @@ -26,7 +27,7 @@ import org.springframework.batch.item.ItemReader; * * @author Lucas Ward */ -public interface Dechunker { +public interface Dechunker extends ItemStream{ /** * Dechunk the provided chunk. In general, this will be done by delegating to an