diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/CheckpointSupport.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/CheckpointSupport.java index 21128be15..6acf8186c 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/CheckpointSupport.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/CheckpointSupport.java @@ -15,10 +15,6 @@ */ package org.springframework.batch.jsr.item; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; import javax.batch.api.chunk.ItemReader; @@ -30,6 +26,7 @@ import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.ItemStreamException; import org.springframework.batch.item.ItemStreamSupport; import org.springframework.util.Assert; +import org.springframework.util.SerializationUtils; /** * Provides support for JSR-352 checkpointing. Checkpoint objects are copied prior @@ -122,14 +119,7 @@ public abstract class CheckpointSupport extends ItemStreamSupport{ Object obj = orig; try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bos); - out.writeObject(orig); - out.flush(); - out.close(); - - ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())); - obj = in.readObject(); + obj = SerializationUtils.deserialize(SerializationUtils.serialize(orig)); } catch (Exception e) { logger.warn("Unable to copy checkpoint object. Updating the instance passed may cause side effects"); } diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java index 134f82931..27c407333 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/jsr/item/ItemReaderAdapter.java @@ -19,9 +19,6 @@ import java.io.Serializable; import javax.batch.api.chunk.ItemReader; -import org.springframework.batch.item.NonTransientResourceException; -import org.springframework.batch.item.ParseException; -import org.springframework.batch.item.UnexpectedInputException; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -53,8 +50,7 @@ public class ItemReaderAdapter extends CheckpointSupport implements org.springfr * @see org.springframework.batch.item.ItemReader#read() */ @Override - public Object read() throws Exception, UnexpectedInputException, ParseException, - NonTransientResourceException { + public Object read() throws Exception { return delegate.readItem(); }