Skip to content

Commit 4f91956

Browse files
authored
Fix getOriginalExecutionRunId return value and add explicit @nonnull annotations (#1737)
1 parent 0b7d1b7 commit 4f91956

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

temporal-sdk/src/main/java/io/temporal/internal/replay/BasicWorkflowContext.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ WorkflowType getWorkflowType() {
7272
return startedAttributes.getWorkflowType();
7373
}
7474

75-
public String getFirstExecutionRunId() {
75+
@Nonnull
76+
String getFirstExecutionRunId() {
7677
return startedAttributes.getFirstExecutionRunId();
7778
}
7879

@@ -81,9 +82,9 @@ Optional<String> getContinuedExecutionRunId() {
8182
return runId.isEmpty() ? Optional.empty() : Optional.of(runId);
8283
}
8384

84-
Optional<String> getOriginalExecutionRunId() {
85-
String runId = startedAttributes.getOriginalExecutionRunId();
86-
return runId.isEmpty() ? Optional.empty() : Optional.of(runId);
85+
@Nonnull
86+
String getOriginalExecutionRunId() {
87+
return startedAttributes.getOriginalExecutionRunId();
8788
}
8889

8990
WorkflowExecution getParentWorkflowExecution() {

temporal-sdk/src/main/java/io/temporal/internal/replay/ReplayWorkflowContext.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ public Functions.Proc1<Exception> getCancellationHandle() {
8484
* @see #getFirstExecutionRunId() for the very first RunId that is preserved along the whole
8585
* Workflow Execution chain, including ContinueAsNew, Retry, Cron and Reset.
8686
*/
87+
@Nonnull
8788
String getRunId();
8889

8990
/**
9091
* @return The very first original RunId of the current Workflow Execution preserved along the
9192
* chain of ContinueAsNew, Retry, Cron and Reset. Identifies the whole Runs chain of Workflow
9293
* Execution.
9394
*/
95+
@Nonnull
9496
String getFirstExecutionRunId();
9597

9698
/**
@@ -108,7 +110,8 @@ public Functions.Proc1<Exception> getCancellationHandle() {
108110
* @see #getFirstExecutionRunId() for the very first RunId that is preserved along the whole
109111
* Workflow Execution chain, including ContinueAsNew, Retry, Cron and Reset.
110112
*/
111-
Optional<String> getOriginalExecutionRunId();
113+
@Nonnull
114+
String getOriginalExecutionRunId();
112115

113116
/** Workflow task queue name. */
114117
String getTaskQueue();

temporal-sdk/src/main/java/io/temporal/internal/replay/ReplayWorkflowContextImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Optional<String> getContinuedExecutionRunId() {
120120
}
121121

122122
@Override
123-
public Optional<String> getOriginalExecutionRunId() {
123+
public String getOriginalExecutionRunId() {
124124
return basicWorkflowContext.getOriginalExecutionRunId();
125125
}
126126

@@ -150,6 +150,7 @@ public String getWorkflowId() {
150150
return basicWorkflowContext.getWorkflowExecution().getWorkflowId();
151151
}
152152

153+
@Nonnull
153154
@Override
154155
public String getRunId() {
155156
String result = basicWorkflowContext.getWorkflowExecution().getRunId();

temporal-sdk/src/main/java/io/temporal/internal/sync/WorkflowInfoImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import io.temporal.workflow.WorkflowInfo;
2727
import java.time.Duration;
2828
import java.util.Optional;
29+
import javax.annotation.Nonnull;
2930
import javax.annotation.Nullable;
3031

3132
final class WorkflowInfoImpl implements WorkflowInfo {
@@ -51,11 +52,13 @@ public String getWorkflowType() {
5152
return context.getWorkflowType().getName();
5253
}
5354

55+
@Nonnull
5456
@Override
5557
public String getRunId() {
5658
return context.getRunId();
5759
}
5860

61+
@Nonnull
5962
@Override
6063
public String getFirstExecutionRunId() {
6164
return context.getFirstExecutionRunId();
@@ -66,8 +69,9 @@ public Optional<String> getContinuedExecutionRunId() {
6669
return context.getContinuedExecutionRunId();
6770
}
6871

72+
@Nonnull
6973
@Override
70-
public Optional<String> getOriginalExecutionRunId() {
74+
public String getOriginalExecutionRunId() {
7175
return context.getOriginalExecutionRunId();
7276
}
7377

temporal-sdk/src/main/java/io/temporal/workflow/WorkflowInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.temporal.api.common.v1.SearchAttributes;
2424
import java.time.Duration;
2525
import java.util.Optional;
26+
import javax.annotation.Nonnull;
2627
import javax.annotation.Nullable;
2728

2829
/**
@@ -54,13 +55,15 @@ public interface WorkflowInfo {
5455
* @see #getFirstExecutionRunId() for the very first RunId that is preserved along the whole
5556
* Workflow Execution chain, including ContinueAsNew, Retry, Cron and Reset.
5657
*/
58+
@Nonnull
5759
String getRunId();
5860

5961
/**
6062
* @return The very first original RunId of the current Workflow Execution preserved along the
6163
* chain of ContinueAsNew, Retry, Cron and Reset. Identifies the whole Runs chain of Workflow
6264
* Execution.
6365
*/
66+
@Nonnull
6467
String getFirstExecutionRunId();
6568

6669
/**
@@ -78,7 +81,8 @@ public interface WorkflowInfo {
7881
* @see #getFirstExecutionRunId() for the very first RunId that is preserved along the whole
7982
* Workflow Execution chain, including ContinueAsNew, Retry, Cron and Reset.
8083
*/
81-
Optional<String> getOriginalExecutionRunId();
84+
@Nonnull
85+
String getOriginalExecutionRunId();
8286

8387
/**
8488
* @return Workflow Task Queue name

temporal-testing/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,27 @@ public String getWorkflowId() {
126126
return "dummy-workflow-id";
127127
}
128128

129+
@Nonnull
129130
@Override
130131
public String getRunId() {
131132
return "dummy-run-id";
132133
}
133134

135+
@Nonnull
134136
@Override
135137
public String getFirstExecutionRunId() {
136-
return null;
138+
throw new UnsupportedOperationException("not implemented");
137139
}
138140

139141
@Override
140142
public Optional<String> getContinuedExecutionRunId() {
141143
throw new UnsupportedOperationException("not implemented");
142144
}
143145

146+
@Nonnull
144147
@Override
145-
public Optional<String> getOriginalExecutionRunId() {
146-
return Optional.empty();
148+
public String getOriginalExecutionRunId() {
149+
throw new UnsupportedOperationException("not implemented");
147150
}
148151

149152
@Override

0 commit comments

Comments
 (0)