diff --git a/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java index c113ce2a..45fef518 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/executor/FlowExecutorImpl.java @@ -139,7 +139,13 @@ public class FlowExecutorImpl implements FlowExecutor { FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition); flowExecution.start(input, context); if (!flowExecution.hasEnded()) { - executionRepository.putFlowExecution(flowExecution); + FlowExecutionLock lock = executionRepository.getLock(flowExecution.getKey()); + lock.lock(); + try { + executionRepository.putFlowExecution(flowExecution); + } finally { + lock.unlock(); + } return createPausedResult(flowExecution); } else { return createEndResult(flowExecution); diff --git a/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java b/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java index 65c556ef..cc851048 100644 --- a/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java +++ b/spring-webflow/src/test/java/org/springframework/webflow/executor/FlowExecutorImplTests.java @@ -53,11 +53,19 @@ public class FlowExecutorImplTests extends TestCase { execution.hasEnded(); EasyMock.expectLastCall().andReturn(Boolean.FALSE); + MockFlowExecutionKey flowExecutionKey = new MockFlowExecutionKey("12345"); + EasyMock.expect(execution.getKey()).andReturn(flowExecutionKey); + EasyMock.expect(repository.getLock(flowExecutionKey)).andReturn(lock); + + lock.lock(); + repository.putFlowExecution(execution); + lock.unlock(); + EasyMock.expect(execution.getDefinition()).andReturn(definition); EasyMock.expect(definition.getId()).andReturn("foo"); - EasyMock.expect(execution.getKey()).andReturn(new MockFlowExecutionKey("12345")); + EasyMock.expect(execution.getKey()).andReturn(flowExecutionKey); replayMocks();