RESOLVED - BATCH-900: Retreive null values from the ExecutionContext
This commit is contained in:
@@ -34,6 +34,14 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ExecutionContext implements Serializable {
|
||||
|
||||
/**
|
||||
* Underlying {@link ConcurrentHashMap} does not accept <code>null</code>
|
||||
* values, so we convert it to a private constant under the covers.
|
||||
*/
|
||||
private static enum Constants {
|
||||
NULL
|
||||
};
|
||||
|
||||
private volatile boolean dirty = false;
|
||||
|
||||
private final Map<String, Object> map;
|
||||
@@ -112,6 +120,9 @@ public class ExecutionContext implements Serializable {
|
||||
if (value != null) {
|
||||
Assert.isInstanceOf(Serializable.class, value, "Value: [ " + value + "must be serializable.");
|
||||
}
|
||||
else {
|
||||
value = Constants.NULL;
|
||||
}
|
||||
dirty = true;
|
||||
map.put(key, value);
|
||||
}
|
||||
@@ -233,6 +244,10 @@ public class ExecutionContext implements Serializable {
|
||||
|
||||
Object value = map.get(key);
|
||||
|
||||
if (value == Constants.NULL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!type.isInstance(value)) {
|
||||
throw new ClassCastException("Value for key=[" + key + "] is not of type: [" + type + "], it is ["
|
||||
+ (value == null ? null : "(" + value.getClass() + ")" + value) + "]");
|
||||
|
||||
Reference in New Issue
Block a user