diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index 57f7eb6dc..9898770d2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -107,7 +107,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement executionContext.putDouble(key, rs.getDouble("DOUBLE_VAL")); } else if (type == AttributeType.OBJECT) { - executionContext.put(key, rs.getObject("OBJECT_VAL")); + executionContext.put(key, SerializationUtils.deserialize(rs.getBinaryStream("OBJECT_VAL"))); } else { throw new UnexpectedJobExecutionException("Invalid type found: [" + typeCd diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java index 6fb65b2eb..4118dffda 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java @@ -201,5 +201,15 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona } } + + public void testStoreInteger(){ + dao.saveStepExecution(stepExecution); + ExecutionContext ec = new ExecutionContext(); + ec.put("intValue", new Integer(343232)); + stepExecution.setExecutionContext(ec); + dao.saveOrUpdateExecutionContext(stepExecution); + ExecutionContext restoredEc = dao.findExecutionContext(stepExecution); + assertEquals(ec, restoredEc); + } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java index a030419d3..e50075925 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java @@ -17,5 +17,5 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests { protected String[] getConfigLocations() { return new String[] { "sql-dao-test.xml" }; } - + } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java index a5b0f1c05..8a81e6c06 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/StatefulRetryStepFactoryBeanTests.java @@ -134,14 +134,14 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { public void testSkipAndRetry() throws Exception { factory.setSkippableExceptionClasses(new Class[] {Exception.class}); - factory.setSkipLimit(1); + factory.setSkipLimit(2); List items = TransactionAwareProxyFactory.createTransactionalList(); - items.addAll(Arrays.asList(new String[] { "a", "b", "c" })); + items.addAll(Arrays.asList(new String[] { "a", "b", "c", "d", "e", "f" })); ItemReader provider = new ListItemReader(items) { public Object read() { Object item = super.read(); count++; - if ("b".equals(item)) { + if ("b".equals(item) || "d".equals(item)) { throw new RuntimeException("Read error - planned but skippable."); } return item; @@ -154,8 +154,45 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase { StepExecution stepExecution = new StepExecution(step, jobExecution); step.execute(stepExecution); - assertEquals(1, stepExecution.getSkipCount()); + assertEquals(2, stepExecution.getSkipCount()); // b is processed once and skipped, plus 1, plus c, plus the null at end - assertEquals(4, count); + assertEquals(7, count); } + + //The following test fails due to current expected behavior of retry + //that will be addressed in 1.1 +// public void testSkipAndRetryWithWriteFailure() throws Exception { +// +// factory.setSkippableExceptionClasses(new Class[] {RetryException.class}); +// factory.setSkipLimit(2); +// List items = TransactionAwareProxyFactory.createTransactionalList(); +// items.addAll(Arrays.asList(new String[] { "a", "b", "c", "d", "e", "f" })); +// ItemReader provider = new ListItemReader(items) { +// public Object read() { +// Object item = super.read(); +// System.out.print("Read Called! Item: [" + item + "]"); +// count++; +// return item; +// } +// }; +// +// ItemWriter itemWriter = new AbstractItemWriter(){ +// public void write(Object item) throws Exception { +// System.out.print("Write Called! Item: [" + item + "]"); +// if ("b".equals(item) || "d".equals(item)) { +// throw new RuntimeException("Read error - planned but skippable."); +// } +// }}; +// factory.setItemReader(provider); +// factory.setItemWriter(itemWriter); +// factory.setRetryLimit(5); +// factory.setRetryableExceptionClasses(new Class[]{RuntimeException.class}); +// AbstractStep step = (AbstractStep) factory.getObject(); +// step.setName("mytest"); +// StepExecution stepExecution = new StepExecution(step, jobExecution); +// step.execute(stepExecution); +// +// assertEquals(2, stepExecution.getSkipCount()); +// assertEquals(9, count); +// } }