Skip to content

Commit

Permalink
fix null pointer exception when getting deploymentId
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Oct 6, 2023
1 parent c62d145 commit 99e62a0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.jbpm.process.core.timer;

import org.drools.core.time.JobContext;
import org.jbpm.process.core.timer.impl.GlobalTimerService.GlobalJobHandle;
import org.jbpm.process.instance.timer.TimerManager.ProcessJobContext;
import org.jbpm.process.instance.timer.TimerManager.StartProcessJobContext;
import org.kie.api.runtime.EnvironmentName;
Expand Down Expand Up @@ -55,7 +56,16 @@ public static String getGroupName(JobContext ctx) {
String groupName = "jbpm";
if (ctx instanceof ProcessJobContext) {
ProcessJobContext processCtx = (ProcessJobContext) ctx;
String deploymentId = (String) processCtx.getKnowledgeRuntime().getEnvironment().get(EnvironmentName.DEPLOYMENT_ID);

String deploymentId = null;
if (processCtx.getJobHandle() instanceof GlobalJobHandle) {
deploymentId = ((GlobalJobHandle) processCtx.getJobHandle()).getDeploymentId();
}

if (deploymentId == null) {
deploymentId = (String) processCtx.getKnowledgeRuntime().getEnvironment().get(EnvironmentName.DEPLOYMENT_ID);
}

if (deploymentId != null) {
groupName = deploymentId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ public GlobalJobHandle(long id) {
super(id);
}

public String getDeploymentId() {
return null;
}

public Long getTimerId() {
JobContext ctx = this.getTimerJobInstance().getJobContext();
if (ctx instanceof SelfRemovalJobContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ public void cancelTimer(long processInstnaceId, long timerId) {
}

public void dispose() {
// for ( TimerInstance timer : timers.values() ) {
// timerService.removeJob( timer.getJobHandle() );
// }
if (timerService instanceof RegisteredTimerServiceDelegate) {
timers.clear();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public String toString() {
return "EjbGlobalJobHandle [uuid=" + getUuid() + "]";
}

@Override
public String getDeploymentId() {
return deploymentId;
}
Expand Down

0 comments on commit 99e62a0

Please sign in to comment.