Skip to content

Commit

Permalink
Limit workflow timeout to non-negative
Browse files Browse the repository at this point in the history
Signed-off-by: Junwei Dai <[email protected]>
  • Loading branch information
Junwei Dai committed Jan 13, 2025
1 parent 84f829c commit ffdc699
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
public class WorkflowTimeoutUtility {

private static final Logger logger = LogManager.getLogger(WorkflowTimeoutUtility.class);
private static final TimeValue MAX_TIMEOUT_MILLIS = TimeValue.timeValueSeconds(300);
private static final TimeValue MIN_TIMEOUT_MILLIS = TimeValue.timeValueSeconds(1);
private static final TimeValue MIN_TIMEOUT_MILLIS = TimeValue.timeValueSeconds(0);

/**
* Schedules a timeout task for a workflow execution.
Expand All @@ -53,8 +52,8 @@ public static ActionListener<WorkflowResponse> scheduleTimeoutHandler(
long timeout,
AtomicBoolean isResponseSent
) {
long adjustedTimeout = Math.min(timeout, MAX_TIMEOUT_MILLIS.millis());
adjustedTimeout = Math.max(adjustedTimeout, MIN_TIMEOUT_MILLIS.millis());
// Ensure timeout is within the valid range (non-negative)
long adjustedTimeout = Math.max(timeout, MIN_TIMEOUT_MILLIS.millis());
Scheduler.ScheduledCancellable scheduledCancellable = threadPool.schedule(
new WorkflowTimeoutListener(client, workflowId, listener, isResponseSent),
TimeValue.timeValueMillis(adjustedTimeout),
Expand Down

0 comments on commit ffdc699

Please sign in to comment.