-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in CmmnRuntimeService#getVariable when used in nested command…
… context, where during looping a wrongly cached variable instance is returned. More specifically: the iteration order of the hashmap changes depending on the amount of variables stored during the same transaction.
- Loading branch information
Showing
11 changed files
with
594 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...flowable-cmmn-engine-configurator/src/test/java/org/flowable/cmmn/test/VariablesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.flowable.cmmn.test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
|
||
import org.flowable.cmmn.api.runtime.CaseInstance; | ||
import org.flowable.cmmn.engine.test.CmmnDeployment; | ||
import org.flowable.cmmn.engine.test.impl.CmmnHistoryTestHelper; | ||
import org.flowable.common.engine.impl.history.HistoryLevel; | ||
import org.flowable.engine.test.Deployment; | ||
import org.flowable.variable.api.history.HistoricVariableInstance; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Joram Barrez | ||
*/ | ||
public class VariablesTest extends AbstractProcessEngineIntegrationTest { | ||
|
||
@Test | ||
@Deployment | ||
@CmmnDeployment | ||
public void testSettingAndRemovingVariableThroughCmmnRuntimeService() { | ||
processEngineRepositoryService.createDeployment() | ||
.addClasspathResource("org/flowable/cmmn/test/VariablesTest.testSettingAndRemovingVariableThroughCmmnRuntimeService.bpmn20.xml") | ||
.deploy(); | ||
|
||
CaseInstance caseInstance = cmmnRuntimeService.createCaseInstanceBuilder() | ||
.caseDefinitionKey("varSyncTestCase") | ||
.variable("loopNum", 100) | ||
.variable("round", 5) | ||
.start(); | ||
|
||
// The case instance ending means all variable lookups succeeded | ||
assertCaseInstanceEnded(caseInstance); | ||
assertThat(cmmnRuntimeService.getVariables(caseInstance.getId())).isEmpty(); | ||
|
||
if (CmmnHistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, cmmnEngineConfiguration)) { | ||
List<HistoricVariableInstance> historicVariables = cmmnHistoryService.createHistoricVariableInstanceQuery() | ||
.caseInstanceId(caseInstance.getId()).list(); | ||
|
||
// The variables are recreated each loop with a non-null value | ||
assertThat(historicVariables).hasSize(102); // 100 from the variables and 2 for round and loopNum | ||
for (HistoricVariableInstance historicVariable : historicVariables) { | ||
assertThat(historicVariable.getValue()).isNotNull(); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.