Skip to content

Commit

Permalink
Revert "[kie-issues#843] Replace random UUID generator with a determi…
Browse files Browse the repository at this point in the history
…nistic random one. (apache#3394)"

This reverts commit a8b1de3.
  • Loading branch information
baldimir committed Feb 9, 2024
1 parent 2e15b49 commit 47d8b0e
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.regex.Matcher;
Expand All @@ -52,7 +53,6 @@
import org.jbpm.process.core.impl.DataTransformerRegistry;
import org.jbpm.ruleflow.core.RuleFlowProcess;
import org.jbpm.util.PatternConstants;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.DroolsAction;
import org.jbpm.workflow.core.Node;
import org.jbpm.workflow.core.NodeContainer;
Expand Down Expand Up @@ -650,7 +650,7 @@ private String cleanUp(String expression) {
}

private DataDefinition toDataExpression(String expression) {
DataDefinition dataSpec = new DataDefinition(UUIDGenerator.getID(), "EXPRESSION (" + expression + ")", null);
DataDefinition dataSpec = new DataDefinition(UUID.randomUUID().toString(), "EXPRESSION (" + expression + ")", null);
dataSpec.setExpression(expression);
return dataSpec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.jbpm.compiler.canonical;

import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;

Expand Down Expand Up @@ -118,9 +117,7 @@ public void visitNode(String factoryField, T node, BlockStmt body, VariableScope
}

protected void addWorkItemParameters(Work work, BlockStmt body, String variableName) {
// This is to ensure that each run of the generator produces the same code.
final List<Entry<String, Object>> sortedParameters = work.getParameters().entrySet().stream().sorted(Entry.comparingByKey()).toList();
for (Entry<String, Object> entry : sortedParameters) {
for (Entry<String, Object> entry : work.getParameters().entrySet()) {
if (entry.getValue() == null) {
continue; // interfaceImplementationRef ?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

import org.jbpm.process.instance.ProcessInstanceManager;
import org.jbpm.util.UUIDGenerator;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;

public class DefaultProcessInstanceManager implements ProcessInstanceManager {
Expand All @@ -36,7 +36,7 @@ public class DefaultProcessInstanceManager implements ProcessInstanceManager {

public void addProcessInstance(KogitoProcessInstance processInstance) {
if (Objects.isNull(processInstance.getStringId())) {
((org.jbpm.process.instance.ProcessInstance) processInstance).setId(UUIDGenerator.getID());
((org.jbpm.process.instance.ProcessInstance) processInstance).setId(UUID.randomUUID().toString());
}
internalAddProcessInstance(processInstance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import java.io.Serializable;
import java.util.Map;
import java.util.UUID;

import org.jbpm.process.instance.impl.Action;
import org.jbpm.ruleflow.core.Metadata;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.impl.NodeIoHelper;
import org.jbpm.workflow.instance.impl.NodeInstanceImpl;
import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
Expand All @@ -45,7 +45,7 @@ public HandleMessageAction(String messageType, String variableName) {
@Override
public void execute(KogitoProcessContext context) throws Exception {
KogitoWorkItemImpl workItem = new KogitoWorkItemImpl();
workItem.setId(UUIDGenerator.getID());
workItem.setId(UUID.randomUUID().toString());
workItem.setName("Send Task");
workItem.setNodeInstanceId((context.getNodeInstance()).getStringId());
workItem.setProcessInstanceId((context.getProcessInstance()).getStringId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function;

import org.jbpm.process.instance.impl.Action;
import org.jbpm.process.instance.impl.util.VariableUtil;
import org.jbpm.util.UUIDGenerator;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void execute(KogitoProcessContext context) throws Exception {
context.getProcessInstance().signalEvent(signalName, signal);
} else if (EXTERNAL_SCOPE.equals(scope)) {
KogitoWorkItemImpl workItem = new KogitoWorkItemImpl();
workItem.setId(UUIDGenerator.getID());
workItem.setId(UUID.randomUUID().toString());
workItem.setName("External Send Task");
workItem.setNodeInstanceId(context.getNodeInstance().getStringId());
workItem.setProcessInstanceId(context.getProcessInstance().getStringId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.nio.file.Paths;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.instance.NodeInstance;
import org.jbpm.workflow.instance.node.WorkItemNodeInstance;
import org.kie.kogito.MapOutput;
Expand Down Expand Up @@ -179,6 +179,6 @@ private static <K extends Serializable, T extends Serializable, C extends TaskMe
}

private static String getNewId() {
return UUIDGenerator.getID();
return UUID.randomUUID().toString();
}
}
37 changes: 0 additions & 37 deletions jbpm/jbpm-flow/src/main/java/org/jbpm/util/UUIDGenerator.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
package org.jbpm.workflow.core.impl;

import java.io.Serializable;

import org.jbpm.util.UUIDGenerator;
import java.util.UUID;

public class DataDefinition implements Serializable {

Expand All @@ -32,7 +31,7 @@ public class DataDefinition implements Serializable {
private String expression;

public DataDefinition(String expression) {
this.id = UUIDGenerator.getID();
this.id = UUID.randomUUID().toString();
this.label = "EXPRESSION - (" + expression + ")";
this.type = "java.lang.Object";
this.expression = expression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Function;
import java.util.function.Predicate;
Expand All @@ -51,7 +52,6 @@
import org.jbpm.process.instance.impl.ProcessInstanceImpl;
import org.jbpm.ruleflow.core.Metadata;
import org.jbpm.util.PatternConstants;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.DroolsAction;
import org.jbpm.workflow.core.Node;
import org.jbpm.workflow.core.impl.NodeImpl;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void addNodeInstance(final NodeInstance nodeInstance) {
if (nodeInstance.getStringId() == null) {
// assign new id only if it does not exist as it might already be set by marshalling
// it's important to keep same ids of node instances as they might be references e.g. exclusive group
((NodeInstanceImpl) nodeInstance).setId(UUIDGenerator.getID());
((NodeInstanceImpl) nodeInstance).setId(UUID.randomUUID().toString());
}
this.nodeInstances.add(nodeInstance);
}
Expand Down Expand Up @@ -563,7 +563,7 @@ public TimerInstance configureSLATimer(String slaDueDateExpression) {

private TimerInstance createDurationTimer(long duration) {
TimerInstance timerInstance = new TimerInstance();
timerInstance.setId(UUIDGenerator.getID());
timerInstance.setId(UUID.randomUUID().toString());
timerInstance.setTimerId("-1");
timerInstance.setDelay(duration);
timerInstance.setPeriod(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function;
import java.util.function.Predicate;

import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.Node;
import org.jbpm.workflow.core.node.CompositeNode;
import org.jbpm.workflow.core.node.EventNode;
Expand Down Expand Up @@ -191,7 +191,7 @@ public void addNodeInstance(final NodeInstance nodeInstance) {
if (nodeInstance.getStringId() == null) {
// assign new id only if it does not exist as it might already be set by marshalling
// it's important to keep same ids of node instances as they might be references e.g. exclusive group
((NodeInstanceImpl) nodeInstance).setId(UUIDGenerator.getID());
((NodeInstanceImpl) nodeInstance).setId(UUID.randomUUID().toString());
}
this.nodeInstances.add(nodeInstance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;

import org.drools.core.common.InternalWorkingMemory;
import org.jbpm.process.instance.InternalProcessRuntime;
import org.jbpm.process.instance.ProcessInstance;
import org.jbpm.util.PatternConstants;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.instance.WorkflowProcessInstance;
import org.jbpm.workflow.instance.impl.MVELProcessHelper;
import org.jbpm.workflow.instance.impl.NodeInstanceImpl;
Expand Down Expand Up @@ -94,7 +94,7 @@ private static void internalAddDynamicWorkItem(
String workItemName,
Map<String, Object> parameters) {
final KogitoWorkItemImpl workItem = new KogitoWorkItemImpl();
workItem.setId(UUIDGenerator.getID());
workItem.setId(UUID.randomUUID().toString());
workItem.setState(WorkItem.ACTIVE);
workItem.setProcessInstanceId(processInstance.getStringId());
workItem.setDeploymentId((String) ksession.getEnvironment().get(EnvironmentName.DEPLOYMENT_ID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

import org.jbpm.process.core.context.exception.ExceptionScope;
import org.jbpm.process.instance.InternalProcessRuntime;
import org.jbpm.process.instance.context.exception.ExceptionScopeInstance;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.Node;
import org.jbpm.workflow.core.node.TimerNode;
import org.kie.api.runtime.process.EventListener;
Expand Down Expand Up @@ -77,7 +77,7 @@ public void internalTrigger(KogitoNodeInstance from, String type) {
if (getTimerInstances() == null) {
addTimerListener();
}
internalSetTimerId(UUIDGenerator.getID());
internalSetTimerId(UUID.randomUUID().toString());
final InternalProcessRuntime processRuntime = (InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime();
//Deffer the timer scheduling to the end of current UnitOfWork execution chain
processRuntime.getUnitOfWorkManager().currentUnitOfWork().intercept(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;

import org.drools.core.WorkItemHandlerNotFoundException;
Expand All @@ -46,7 +47,6 @@
import org.jbpm.process.instance.context.variable.VariableScopeInstance;
import org.jbpm.process.instance.impl.ContextInstanceFactory;
import org.jbpm.process.instance.impl.ContextInstanceFactoryRegistry;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.Node;
import org.jbpm.workflow.core.impl.DataAssociation;
import org.jbpm.workflow.core.impl.NodeIoHelper;
Expand Down Expand Up @@ -222,7 +222,7 @@ protected InternalKogitoWorkItem newWorkItem() {
protected InternalKogitoWorkItem createWorkItem(WorkItemNode workItemNode) {
Work work = workItemNode.getWork();
workItem = newWorkItem();
workItem.setId(UUIDGenerator.getID());
workItem.setId(UUID.randomUUID().toString());
workItem.setName(work.getName());
workItem.setProcessInstanceId(getProcessInstance().getStringId());
workItem.setProcessInstance(this.getKogitoProcessInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/
package org.kie.kogito.process.impl;

import java.util.UUID;

import org.jbpm.process.instance.impl.DefaultProcessInstanceManager;
import org.jbpm.util.UUIDGenerator;
import org.junit.jupiter.api.Test;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;

Expand All @@ -33,7 +34,7 @@ public class DefaultProcessInstanceManagerTest {
public void testCreateProcessInstance() {
DefaultProcessInstanceManager pim = new DefaultProcessInstanceManager();
final String processId = "processId";
final String instanceId = UUIDGenerator.getID();
final String instanceId = UUID.randomUUID().toString();
KogitoProcessInstance kpi = mock(KogitoProcessInstance.class);
when(kpi.getProcessId()).thenReturn(processId);
when(kpi.getStringId()).thenReturn(instanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand All @@ -41,7 +42,6 @@
import org.jbpm.process.instance.impl.humantask.InternalHumanTaskWorkItem;
import org.jbpm.process.instance.impl.humantask.Reassignment;
import org.jbpm.ruleflow.instance.RuleFlowProcessInstance;
import org.jbpm.util.UUIDGenerator;
import org.jbpm.workflow.core.node.AsyncEventNodeInstance;
import org.jbpm.workflow.instance.impl.NodeInstanceImpl;
import org.jbpm.workflow.instance.node.CompositeContextNodeInstance;
Expand Down Expand Up @@ -566,7 +566,7 @@ private WorkItemNodeInstance instanceWorkItem(WorkItemNodeInstanceContent conten
} else {
WorkItemNodeInstance nodeInstance = new WorkItemNodeInstance();
KogitoWorkItemImpl workItem = new KogitoWorkItemImpl();
workItem.setId(UUIDGenerator.getID());
workItem.setId(UUID.randomUUID().toString());
nodeInstance.internalSetWorkItem(workItem);
return nodeInstance;
}
Expand Down

0 comments on commit 47d8b0e

Please sign in to comment.