mirror of
https://github.com/keycloak/keycloak.git
synced 2025-12-19 05:20:21 -06:00
Avoid lookup of existing workflow instances when not needed
Closes #44791 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This commit is contained in:
committed by
GitHub
parent
1d16429530
commit
1231590a52
@@ -235,8 +235,7 @@ public class DefaultWorkflowProvider implements WorkflowProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processEvent(Stream<Workflow> workflows, WorkflowEvent event) {
|
private void processEvent(Stream<Workflow> workflows, WorkflowEvent event) {
|
||||||
Map<String, ScheduledStep> scheduledSteps = stateProvider.getScheduledStepsByResource(event.getResourceId())
|
Map<String, ScheduledStep>[] scheduledSteps = new Map[] { null };
|
||||||
.collect(Collectors.toMap(ScheduledStep::workflowId, Function.identity()));
|
|
||||||
|
|
||||||
workflows.forEach(workflow -> {
|
workflows.forEach(workflow -> {
|
||||||
if (!workflow.isEnabled()) {
|
if (!workflow.isEnabled()) {
|
||||||
@@ -247,9 +246,20 @@ public class DefaultWorkflowProvider implements WorkflowProvider {
|
|||||||
EventBasedWorkflow provider = new EventBasedWorkflow(session, getWorkflowComponent(workflow.getId()));
|
EventBasedWorkflow provider = new EventBasedWorkflow(session, getWorkflowComponent(workflow.getId()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ScheduledStep scheduledStep = scheduledSteps.get(workflow.getId());
|
if (!provider.supports(event.getResourceType())) {
|
||||||
|
// Prevents loading of scheduled steps when this resource type is not supported for the workflow
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DefaultWorkflowExecutionContext context = new DefaultWorkflowExecutionContext(session, workflow, event);
|
DefaultWorkflowExecutionContext context = new DefaultWorkflowExecutionContext(session, workflow, event);
|
||||||
|
|
||||||
|
if (scheduledSteps[0] == null) {
|
||||||
|
// Lazily loading the current steps for this resource
|
||||||
|
scheduledSteps[0] = stateProvider.getScheduledStepsByResource(event.getResourceId())
|
||||||
|
.collect(Collectors.toMap(ScheduledStep::workflowId, Function.identity()));
|
||||||
|
}
|
||||||
|
ScheduledStep scheduledStep = scheduledSteps[0].get(workflow.getId());
|
||||||
|
|
||||||
// if workflow is not active for the resource, check if the provider allows activating based on the event
|
// if workflow is not active for the resource, check if the provider allows activating based on the event
|
||||||
if (scheduledStep == null) {
|
if (scheduledStep == null) {
|
||||||
if (provider.activate(context)) {
|
if (provider.activate(context)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user