From 76c9dbba8060387541369dab8c32c187a1668ae9 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 7 Apr 2010 20:17:51 +0000 Subject: [PATCH] SWF-1213 Added calls to lock/unlock the conversation when an execution is launched. This causes the conversation to be put back into the HTTP session. --- .../webflow/executor/FlowExecutorImpl.java | 8 +++++++- .../webflow/executor/FlowExecutorImplTests.java | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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();