Skip to content

Commit

Permalink
fix(engine): when dmn is disabled do not delete dmn deployments
Browse files Browse the repository at this point in the history
* This commit fixes a bug related to DMN. When DMN is disabled, there
  shouldn't be any operations to the related DMN tables. However, when a
Process Application is undeployed, and DMN is disabled, the undeployment
will attempt to delete the Decision Requirements Definitions as well.
This will result in an exception (missing table).
* Furthermore, the CmmnModelInstanceCache will also attempt to query
  Decision Definitions on undeploy. This is also fixed here.

Related to CAM-13205, closes camunda#1365, camunda#1459
  • Loading branch information
marcus-nl authored and koevskinikola committed May 18, 2021
1 parent ecb76ee commit 1848980
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package org.camunda.bpm.engine.impl.persistence.deploy.cache;

import org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity;
import org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionQueryImpl;
import org.camunda.bpm.engine.repository.DecisionDefinition;
import org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionQueryImpl;
import org.camunda.bpm.engine.repository.CaseDefinition;
import org.camunda.bpm.model.cmmn.Cmmn;
import org.camunda.bpm.model.cmmn.CmmnModelInstance;

Expand Down Expand Up @@ -50,8 +50,8 @@ protected void logRemoveEntryFromDeploymentCacheFailure(String definitionId, Exc
}

@Override
protected List<DecisionDefinition> getAllDefinitionsForDeployment(String deploymentId) {
return new DecisionDefinitionQueryImpl()
protected List<CaseDefinition> getAllDefinitionsForDeployment(String deploymentId) {
return new CaseDefinitionQueryImpl()
.deploymentId(deploymentId)
.list();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ public void setDeployers(List<Deployer> deployers) {

public void removeDeployment(String deploymentId) {
bpmnModelInstanceCache.removeAllDefinitionsByDeploymentId(deploymentId);
if(Context.getProcessEngineConfiguration().isCmmnEnabled()) {
if (Context.getProcessEngineConfiguration().isCmmnEnabled()) {
cmmnModelInstanceCache.removeAllDefinitionsByDeploymentId(deploymentId);
}
if(Context.getProcessEngineConfiguration().isDmnEnabled()) {
if (Context.getProcessEngineConfiguration().isDmnEnabled()) {
dmnModelInstanceCache.removeAllDefinitionsByDeploymentId(deploymentId);
removeAllDecisionRequirementsDefinitionsByDeploymentId(deploymentId);
}
removeAllDecisionRequirementsDefinitionsByDeploymentId(deploymentId);
}

protected void removeAllDecisionRequirementsDefinitionsByDeploymentId(String deploymentId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@
*/
package org.camunda.bpm.application.impl.embedded;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;

import java.util.List;
import java.util.Set;

import ch.qos.logback.classic.Level;
import org.camunda.bpm.BpmPlatform;
import org.camunda.bpm.container.RuntimeContainerDelegate;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineConfiguration;
import org.camunda.bpm.engine.impl.ProcessEngineImpl;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.ProcessApplicationDeployment;
import org.camunda.bpm.engine.repository.Resource;
import org.camunda.bpm.engine.test.util.PluggableProcessEngineTest;
import org.camunda.commons.testing.ProcessEngineLoggingRule;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

/**
Expand All @@ -43,6 +45,12 @@
*/
public class EmbeddedProcessApplicationTest extends PluggableProcessEngineTest {

protected static final String CONFIG_LOGGER = "org.camunda.bpm.application";
@Rule
public ProcessEngineLoggingRule loggingRule = new ProcessEngineLoggingRule()
.watch(CONFIG_LOGGER)
.level(Level.WARN);

protected RuntimeContainerDelegate runtimeContainerDelegate = RuntimeContainerDelegate.INSTANCE.get();
protected boolean defaultEngineRegistered;

Expand Down Expand Up @@ -111,6 +119,35 @@ public void testDeployAppWithCustomEngine() {

}

@Test
public void testDeployAppWithoutDmn() {
// given
TestApplicationWithoutDmn processApplication = new TestApplicationWithoutDmn();
processApplication.deploy();

ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("embeddedEngine");
assertNotNull(processEngine);
assertEquals("embeddedEngine", processEngine.getName());

ProcessEngineConfigurationImpl configuration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();

// assert engine properties specified
assertTrue(configuration.isJobExecutorDeploymentAware());
assertTrue(configuration.isJobExecutorPreferTimerJobs());
assertTrue(configuration.isJobExecutorAcquireByDueDate());
assertEquals(5, configuration.getJdbcMaxActiveConnections());
assertFalse(configuration.isDmnEnabled());

// when
processApplication.undeploy();

// then
assertThat(loggingRule
.getFilteredLog("ENGINE-07018 Unregistering process application for deployment but could " +
"not remove process definitions from deployment cache."))
.hasSize(0);
}

@Test
public void testDeployAppWithCustomDefaultEngine() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; 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.camunda.bpm.application.impl.embedded;

import org.camunda.bpm.application.ProcessApplication;
import org.camunda.bpm.application.impl.EmbeddedProcessApplication;

/**
* @author Daniel Meyer
*
*/
@ProcessApplication(
name="test-app",
deploymentDescriptors={"org/camunda/bpm/application/impl/embedded/deployment-without-dmn.xml"}
)
public class TestApplicationWithoutDmn extends EmbeddedProcessApplication {
public TestApplicationWithoutDmn() {
setDefaultDeployToEngineName("embeddedEngine");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<process-application
xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.camunda.org/schema/1.0/ProcessApplication http://www.camunda.org/schema/1.0/ProcessApplication ">

<process-engine name="embeddedEngine">

<configuration>org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration</configuration>

<properties>
<property name="jdbcUrl">jdbc:h2:mem:embeddedEngine</property>
<property name="jobExecutorDeploymentAware">true</property>
<property name="jobExecutorPreferTimerJobs">true</property>
<property name="jobExecutorAcquireByDueDate">true</property>
<property name="jdbcMaxActiveConnections">5</property>
<property name="dmnEnabled">false</property>
</properties>

</process-engine>

<process-archive name="pa1">

<resource>org/camunda/bpm/application/impl/embedded/StartToEndTest.testStartToEnd.bpmn20.xml</resource>

<properties>
<property name="isScanForProcessDefinitions">false</property>
<property name="isDeleteUponUndeploy">true</property>
</properties>

</process-archive>

</process-application>

0 comments on commit 1848980

Please sign in to comment.