Skip to content

Fix NPE in TryExecutor when retry policy omits optional fields#1519

Merged
fjtirado merged 3 commits into
open-workflow-specification:mainfrom
mcruzdev:issue-1517
Jul 9, 2026
Merged

Fix NPE in TryExecutor when retry policy omits optional fields#1519
fjtirado merged 3 commits into
open-workflow-specification:mainfrom
mcruzdev:issue-1517

Conversation

@mcruzdev

@mcruzdev mcruzdev commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

The spec defines backoff, limit, and delay as optional in a retry policy, but the runtime assumed all three were always present, causing NullPointerException when any was omitted.

  • Default to constant backoff when backoff is not specified
  • Default to unlimited retries when limit is not specified
  • Default to zero delay when delay is not specified

Closes #1517

Copilot AI review requested due to automatic review settings July 3, 2026 19:51
@mcruzdev
mcruzdev requested a review from fjtirado as a code owner July 3, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses runtime NullPointerException failures when a RetryPolicy omits optional fields (as allowed by the spec) by adding defaulting/guard logic in the retry executor path and adding regression tests for common omission scenarios.

Changes:

  • Default retry backoff to constant backoff when retryPolicy.backoff is omitted.
  • Default retry limit to a max when retryPolicy.limit / limit.attempt is omitted.
  • Default retry delay to Duration.ZERO when retryPolicy.delay is omitted.
  • Add fluent DSL tests covering retry behavior when backoff, limit, or delay are omitted.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java Adds resolveMaxAttempts() and defaults missing backoff to constant backoff.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/retry/AbstractRetryIntervalFunction.java Defaults missing delay to zero duration via a constant resolver.
experimental/test/src/test/java/io/serverlessworkflow/fluent/test/FuncTryCatchTest.java Adds regression tests for retry policies missing backoff, limit, or delay.
Comments suppressed due to low confidence (1)

impl/core/src/main/java/io/serverlessworkflow/impl/executors/retry/AbstractRetryIntervalFunction.java:42

  • The constructor still dereferences jitter.getFrom() / jitter.getTo() without guarding against them being null. The fluent builder allows setting only one of these, so this path can still throw a NullPointerException even with the top-level jitter != null check. Suggest treating missing from/to as no jitter (Duration.ZERO).
    if (jitter != null) {
      minJitteringResolver = Optional.of(WorkflowUtils.fromTimeoutAfter(appl, jitter.getFrom()));
      maxJitteringResolver = Optional.of(WorkflowUtils.fromTimeoutAfter(appl, jitter.getTo()));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java Outdated

@fjtirado fjtirado left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just usual picky comments ;)

Copilot AI review requested due to automatic review settings July 9, 2026 11:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings July 9, 2026 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/executors/TryExecutor.java Outdated
Copilot AI review requested due to automatic review settings July 9, 2026 12:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings July 9, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 9, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 9, 2026 17:20
@fjtirado
fjtirado force-pushed the issue-1517 branch 3 times, most recently from b599648 to f843a29 Compare July 9, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings July 9, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 9, 2026 17:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 9, 2026 17:35
Signed-off-by: fjtirado <ftirados@ibm.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings July 9, 2026 17:38
@fjtirado
fjtirado merged commit 60baf21 into open-workflow-specification:main Jul 9, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Comment on lines +117 to +121
private static int resolveMaxAttempts(RetryLimit limit) {
return limit != null && limit.getAttempt() != null
? limit.getAttempt().getCount()
: Integer.MAX_VALUE - 1;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #1526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in TryExecutor when retry is configured without explicit backoff strategy

3 participants