From 83e70c84c12da97520bab663f685649a1dd7c5af Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Fri, 6 Dec 2024 08:52:30 -0800 Subject: [PATCH] Update Nexus SDK --- build.gradle | 2 +- .../temporal/internal/common/InternalUtils.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index d8bb288eb..4fce4e12d 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ ext { // Platforms grpcVersion = '1.54.1' // [1.38.0,) Needed for io.grpc.protobuf.services.HealthStatusManager jacksonVersion = '2.14.2' // [2.9.0,) - nexusVersion = '0.2.1-alpha' + nexusVersion = '0.3.0-alpha' // we don't upgrade to 1.10.x because it requires kotlin 1.6. Users may use 1.10.x in their environments though. micrometerVersion = project.hasProperty("edgeDepsTest") ? '1.13.6' : '1.9.9' // [1.0.0,) diff --git a/temporal-sdk/src/main/java/io/temporal/internal/common/InternalUtils.java b/temporal-sdk/src/main/java/io/temporal/internal/common/InternalUtils.java index c00580f17..753e75e77 100644 --- a/temporal-sdk/src/main/java/io/temporal/internal/common/InternalUtils.java +++ b/temporal-sdk/src/main/java/io/temporal/internal/common/InternalUtils.java @@ -21,6 +21,7 @@ package io.temporal.internal.common; import com.google.common.base.Defaults; +import io.nexusrpc.Header; import io.temporal.api.common.v1.Callback; import io.temporal.api.enums.v1.TaskQueueKind; import io.temporal.api.taskqueue.v1.TaskQueue; @@ -28,8 +29,8 @@ import io.temporal.client.WorkflowStub; import io.temporal.internal.client.NexusStartWorkflowRequest; import java.util.Arrays; -import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -83,9 +84,16 @@ public static WorkflowStub createNexusBoundStub( // Add the Nexus operation ID to the headers if it is not already present to support fabricating // a NexusOperationStarted event if the completion is received before the response to a // StartOperation request. - Map headers = new HashMap<>(request.getCallbackHeaders()); - if (!headers.containsKey("nexus-operation-id")) { - headers.put("nexus-operation-id", options.getWorkflowId()); + Map headers = + request.getCallbackHeaders().entrySet().stream() + .collect( + Collectors.toMap( + (k) -> k.getKey().toLowerCase(), + Map.Entry::getValue, + (a, b) -> a, + () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER))); + if (!headers.containsKey(Header.OPERATION_ID)) { + headers.put(Header.OPERATION_ID, options.getWorkflowId()); } WorkflowOptions.Builder nexusWorkflowOptions = WorkflowOptions.newBuilder(options)