BATCH-2156: blocking when the ExecutionContext is updated to prevent transaction serialization issues

This commit is contained in:
Michael Minella
2014-03-26 16:41:24 -05:00
parent dc1a5fcd30
commit 9b5e7a281e

View File

@@ -148,15 +148,18 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
@Override
public void updateExecutionContext(final StepExecution stepExecution) {
// Attempt to prevent concurrent modification errors by blocking here if
// someone is already trying to do it.
synchronized (stepExecution) {
Long executionId = stepExecution.getId();
ExecutionContext executionContext = stepExecution.getExecutionContext();
Assert.notNull(executionId, "ExecutionId must not be null.");
Assert.notNull(executionContext, "The ExecutionContext must not be null.");
Long executionId = stepExecution.getId();
ExecutionContext executionContext = stepExecution.getExecutionContext();
Assert.notNull(executionId, "ExecutionId must not be null.");
Assert.notNull(executionContext, "The ExecutionContext must not be null.");
String serializedContext = serializeContext(executionContext);
String serializedContext = serializeContext(executionContext);
persistSerializedContext(executionId, serializedContext, UPDATE_STEP_EXECUTION_CONTEXT);
persistSerializedContext(executionId, serializedContext, UPDATE_STEP_EXECUTION_CONTEXT);
}
}
@Override