Skip to content

Support direct synchronous returns from Temporal operations - #3206

Merged
litlep-nibbyt merged 1 commit into
nexus-context-free-handler-prototypefrom
nexus-sync-return
Nov 19, 2026
Merged

litlep-nibbyt merged 1 commit into
nexus-context-free-handler-prototypefrom
nexus-sync-return

Conversation

@litlep-nibbyt

Copy link
Copy Markdown
Contributor

What changed?

Allow @TemporalOperation methods to return their output directly:

public String greet(TemporalNexusClient client, String name) {
  return "Hello, " + name;
}

The SDK wraps the value as a synchronous result internally. Existing methods returning TemporalOperationResult<R> continue to work.

Stacked on #3195; this diff contains only direct-return support, documentation, and tests.

Why?

Remove the explicit TemporalOperationResult.sync(...) wrapper from synchronous handlers.

Breaking changes?

None beyond the context changes in #3195.

Server PR

Not required.

Validation

Nexus tests: 173 passed, 15 skipped. Formatting, Javadoc, and git diff --check passed.

@litlep-nibbyt
litlep-nibbyt marked this pull request as ready for review November 17, 2026 01:22
@litlep-nibbyt
litlep-nibbyt requested a review from a team as a code owner November 17, 2026 01:22
@litlep-nibbyt
litlep-nibbyt requested a balanced review from Copilot November 17, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the synchronous Nexus handler direct-return changes.

No open issues 🎉

What changed in this PR

This PR simplifies synchronous Nexus handlers in the Java SDK by allowing @TemporalOperation methods to return output directly. It builds on the context refactor in #3195 while preserving explicit TemporalOperationResult returns.

Changes:

  • Validate direct return types and wrap returned values as synchronous results, including null, primitive, and void outputs.
  • Add unit and workflow tests for direct returns, type validation, failure propagation, and existing wrapped results.
  • Update API documentation, examples, and the changelog.
File Description
temporal-sdk/​src/​test/​java/​io/​temporal/​workflow/​nexus/​TemporalOperationAnnotationTest.java Adds end-to-end coverage for direct output serialization, null results, and failures.
temporal-sdk/​src/​test/​java/​io/​temporal/​internal/​nexus/​TemporalOperationProcessorTest.java Tests direct-return validation, wrapping, and compatibility with wrapped results.
temporal-sdk/​src/​main/​java/​io/​temporal/​nexus/​TemporalOperation.java Documents direct synchronous returns and void support.
temporal-sdk/​src/​main/​java/​io/​temporal/​nexus/​TemporalNexusClient.java Updates synchronous-handler documentation and the signal example.
temporal-sdk/​src/​main/​java/​io/​temporal/​internal/​nexus/​TemporalOperationProcessor.java Accepts direct output types and wraps values in synchronous results.
CHANGELOG.md Announces direct-return support and continued wrapped-result compatibility.

Review effort: Balanced

@litlep-nibbyt
litlep-nibbyt merged commit 748c23f into main Nov 19, 2026
45 of 46 checks passed
@litlep-nibbyt
litlep-nibbyt deleted the nexus-sync-return branch November 19, 2026 00:57
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.

3 participants