Removed serialisable check on ExecutionContext entries
The serialisation/deserialisation implementation is injectable, so it does not make sense to enforce the presence of this interface
This commit is contained in:
committed by
Michael Minella
parent
4e25560c4d
commit
8bfc0d2ab8
@@ -18,6 +18,7 @@ package org.springframework.batch.core.repository.dao;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.batch.core.repository.ExecutionContextSerializer;
|
||||
@@ -54,6 +55,9 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial
|
||||
Assert.notNull(context);
|
||||
Assert.notNull(out);
|
||||
|
||||
for(Object value : context.values()) {
|
||||
Assert.isInstanceOf(Serializable.class, value, "Value: [ " + value + "must be serializable.");
|
||||
}
|
||||
serializer.serialize(context, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,14 @@ public class DefaultExecutionContextSerializerTests {
|
||||
compareContexts(m1, m2);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testSerializeNonSerializable() throws Exception {
|
||||
Map<String, Object> m1 = new HashMap<String, Object>();
|
||||
m1.put("object1", new Object());
|
||||
|
||||
serializer.serialize(m1, new ByteArrayOutputStream());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexObject() throws Exception {
|
||||
Map<String, Object> m1 = new HashMap<String, Object>();
|
||||
|
||||
Reference in New Issue
Block a user