Skip to content

Commit

Permalink
Update Java SDK (#502)
Browse files Browse the repository at this point in the history
Update Java SDK
  • Loading branch information
Quinn-With-Two-Ns authored Jun 27, 2024
1 parent fa5255b commit 6d18b3b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
outputs:
go_latest: '1.26.1'
typescript_latest: '1.10.0'
java_latest: '1.23.0'
java_latest: '1.24.0'
python_latest: '1.6.0'
csharp_latest: '1.1.2'
steps:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.jayway.jsonpath:json-path:2.6.0'
implementation 'info.picocli:picocli:4.6.2'
implementation 'io.temporal:temporal-sdk:1.23.0'
implementation 'io.temporal:temporal-sdk:1.24.0'
implementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
implementation 'org.reflections:reflections:0.10.2'
}
Expand Down
6 changes: 4 additions & 2 deletions features/update/async_accepted/feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io.temporal.activity.ActivityInterface;
import io.temporal.client.UpdateHandle;
import io.temporal.client.UpdateOptions;
import io.temporal.client.UpdateWaitPolicy;
import io.temporal.client.WorkflowUpdateException;
import io.temporal.client.WorkflowUpdateStage;
import io.temporal.failure.ApplicationFailure;
import io.temporal.sdkfeatures.Feature;
import io.temporal.sdkfeatures.Run;
Expand Down Expand Up @@ -77,6 +77,7 @@ public Run execute(Runner runner) throws Exception {
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
true);

Expand All @@ -93,6 +94,7 @@ public Run execute(Runner runner) throws Exception {
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
false);
try {
Expand All @@ -115,7 +117,7 @@ public Run execute(Runner runner) throws Exception {
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitPolicy(UpdateWaitPolicy.ACCEPTED)
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
true);
// Expect to get a timeout exception
Expand Down
4 changes: 2 additions & 2 deletions features/update/deduplication/feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.temporal.client.UpdateHandle;
import io.temporal.client.UpdateOptions;
import io.temporal.client.UpdateWaitPolicy;
import io.temporal.client.WorkflowUpdateStage;
import io.temporal.sdkfeatures.Feature;
import io.temporal.sdkfeatures.Run;
import io.temporal.sdkfeatures.Runner;
Expand Down Expand Up @@ -72,7 +72,7 @@ public Run execute(Runner runner) throws Exception {
UpdateOptions.newBuilder(Integer.class)
.setUpdateName("incrementCount")
.setUpdateId(REUSED_UPDATE_ID)
.setWaitPolicy(UpdateWaitPolicy.ACCEPTED)
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.setFirstExecutionRunId(run.execution.getRunId())
.build();

Expand Down
20 changes: 7 additions & 13 deletions features/update/task_failure/feature.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package update.task_failure;

import io.temporal.activity.ActivityInterface;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowUpdateException;
import io.temporal.failure.ApplicationFailure;
import io.temporal.sdkfeatures.Feature;
Expand All @@ -11,7 +12,7 @@
import io.temporal.workflow.UpdateMethod;
import io.temporal.workflow.UpdateValidatorMethod;
import io.temporal.workflow.Workflow;
import java.util.concurrent.ExecutionException;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Assertions;

Expand Down Expand Up @@ -63,6 +64,11 @@ public void finish() {
this.doFinish = true;
}

@Override
public void workflowOptions(WorkflowOptions.Builder builder) {
builder.setWorkflowTaskTimeout(Duration.ofSeconds(1));
}

@Override
public Run execute(Runner runner) {
runner.skipIfUpdateNotSupported();
Expand All @@ -79,18 +85,6 @@ public Run execute(Runner runner) {
Assertions.assertEquals("Failure", ((ApplicationFailure) e.getCause()).getType());
Assertions.assertEquals(
"message='simulated 3', type='Failure', nonRetryable=false", e.getCause().getMessage());
} catch (RuntimeException e) {
// TODO(https://github.com/temporalio/sdk-java/issues/1973) The SDK should be unwrapping the
// ExecutionException.
Assertions.assertTrue(e.getCause() instanceof ExecutionException);
ExecutionException ee = (ExecutionException) e.getCause();
Assertions.assertTrue(ee.getCause() instanceof WorkflowUpdateException);
WorkflowUpdateException wue = (WorkflowUpdateException) ee.getCause();
Assertions.assertTrue(wue.getCause() instanceof ApplicationFailure);
Assertions.assertEquals("Failure", ((ApplicationFailure) wue.getCause()).getType());
Assertions.assertEquals(
"message='simulated 3', type='Failure', nonRetryable=false",
wue.getCause().getMessage());
}

// Check an update handle validator will fail on any exception
Expand Down
2 changes: 2 additions & 0 deletions harness/go/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ func scrubRunSpecificScalars(v interface{}) {
case *history.ActivityTaskStartedEventAttributes:
v.Identity = ""
v.RequestId = ""
// Disable because cloud may truncate this value
v.LastFailure = nil
// Because binary checksum will show up in the stamp where it didn't before, ignore unless
// versioning was actually turned on.
if v.GetWorkerVersion() != nil && !v.GetWorkerVersion().GetUseVersioning() {
Expand Down
5 changes: 4 additions & 1 deletion harness/java/io/temporal/sdkfeatures/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.temporal.api.workflow.v1.WorkflowExecutionInfo;
import io.temporal.api.workflowservice.v1.DescribeWorkflowExecutionRequest;
import io.temporal.client.*;
import io.temporal.client.WorkflowUpdateStage;
import io.temporal.internal.client.WorkflowClientHelper;
import io.temporal.internal.common.WorkflowExecutionHistory;
import io.temporal.serviceclient.WorkflowServiceStubs;
Expand Down Expand Up @@ -349,7 +350,9 @@ public void skipIfUpdateNotSupported() {

public void skipIfAsyncAcceptedUpdateNotSupported() {
try {
client.newUntypedWorkflowStub("fake").startUpdate("also_fake", Void.class);
client
.newUntypedWorkflowStub("fake")
.startUpdate("also_fake", WorkflowUpdateStage.ACCEPTED, Void.class);
} catch (WorkflowNotFoundException exception) {
return;
} catch (WorkflowServiceException exception) {
Expand Down

0 comments on commit 6d18b3b

Please sign in to comment.