Skip to content

Commit ba20701

Browse files
authored
Retry options serialization NPE fix (#109)
1 parent 2aca4f1 commit ba20701

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/main/java/io/temporal/activity/Activity.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,12 @@ public static ActivityExecutionContext getExecutionContext() {
237237
* try {
238238
* return someCall();
239239
* } catch (Exception e) {
240-
* throw CheckedExceptionWrapper.throwWrapped(e);
240+
* throw Activity.wrap(e);
241241
* }
242242
* </pre>
243243
*
244-
* If throwWrapped returned void it wouldn't be possible to write <code>
245-
* throw CheckedExceptionWrapper.throwWrapped</code> and compiler would complain about missing
246-
* return.
244+
* If wrap returned void it wouldn't be possible to write <code>
245+
* throw Activity.wrap</code> and compiler would complain about missing return.
247246
*
248247
* @return never returns as always throws.
249248
*/

src/main/java/io/temporal/internal/sync/WorkflowRetryerInternal.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,16 @@ private static <R> Promise<R> retryAsync(
187187

188188
private static RetryOptions getRetryOptionsSideEffect(String retryId, RetryOptions options) {
189189
options = RetryOptions.newBuilder(options).validateBuildWithDefaults();
190+
long maximumIntervalMillis =
191+
options.getMaximumInterval() != null ? options.getMaximumInterval().toMillis() : 0;
192+
long initialIntervalMillis =
193+
options.getInitialInterval() != null ? options.getInitialInterval().toMillis() : 0;
190194
SerializableRetryOptions sOptions =
191195
new SerializableRetryOptions(
192-
options.getInitialInterval().toMillis(),
196+
initialIntervalMillis,
193197
options.getBackoffCoefficient(),
194198
options.getMaximumAttempts(),
195-
options.getMaximumInterval().toMillis(),
199+
maximumIntervalMillis,
196200
options.getDoNotRetry());
197201
SerializableRetryOptions sRetryOptions =
198202
WorkflowInternal.mutableSideEffect(

src/main/java/io/temporal/workflow/Workflow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ public static void retry(
821821
* try {
822822
* return someCall();
823823
* } catch (Exception e) {
824-
* throw CheckedExceptionWrapper.wrap(e);
824+
* throw Workflow.wrap(e);
825825
* }
826826
* </pre>
827827
*

src/test/java/io/temporal/workflow/WorkflowTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,7 @@ public String execute(String taskList) {
713713
.setMaximumAttempts(3)
714714
.build();
715715
} else {
716-
retryOptions =
717-
RetryOptions.newBuilder()
718-
.setMaximumInterval(Duration.ofSeconds(1))
719-
.setInitialInterval(Duration.ofSeconds(1))
720-
.setMaximumAttempts(2)
721-
.build();
716+
retryOptions = RetryOptions.newBuilder().setMaximumAttempts(2).build();
722717
}
723718
TestActivities activities = Workflow.newActivityStub(TestActivities.class, options.build());
724719
Workflow.retry(retryOptions, Optional.of(Duration.ofDays(1)), () -> activities.throwIO());

0 commit comments

Comments
 (0)