Skip to content

Commit c7fcf12

Browse files
Make headers in ExecuteNexusOperationInput case insensitive (#2342)
* Make headers in ExecuteNexusOperationInput case insensitive * Ensure all headers sent are lower case * run spotless
1 parent cbcf26c commit c7fcf12

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowOutboundCallsInterceptor.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.*;
3434
import java.util.function.BiPredicate;
3535
import java.util.function.Supplier;
36+
import java.util.stream.Collectors;
3637
import javax.annotation.Nullable;
3738

3839
/**
@@ -285,7 +286,14 @@ public ExecuteNexusOperationInput(
285286
this.resultType = resultType;
286287
this.arg = arg;
287288
this.options = options;
288-
this.headers = headers;
289+
this.headers =
290+
headers.entrySet().stream()
291+
.collect(
292+
Collectors.toMap(
293+
(k) -> k.getKey().toLowerCase(),
294+
Map.Entry::getValue,
295+
(a, b) -> a,
296+
() -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER)));
289297
}
290298

291299
public String getService() {
@@ -316,6 +324,10 @@ public NexusOperationOptions getOptions() {
316324
return options;
317325
}
318326

327+
/**
328+
* Get headers that will be sent with the request. The returned map operates without regard to
329+
* case.
330+
*/
319331
public Map<String, String> getHeaders() {
320332
return headers;
321333
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,8 @@ public <R> ExecuteNexusOperationOutput<R> executeNexusOperation(
816816
attributes.setOperation(input.getOperation());
817817
attributes.setService(input.getService());
818818
attributes.setEndpoint(input.getEndpoint());
819-
attributes.putAllNexusHeader(input.getHeaders());
819+
// Ensure that the headers are lowercase
820+
input.getHeaders().forEach((k, v) -> attributes.putNexusHeader(k.toLowerCase(), v));
820821
attributes.setScheduleToCloseTimeout(
821822
ProtobufTimeUtils.toProtoDuration(input.getOptions().getScheduleToCloseTimeout()));
822823

0 commit comments

Comments
 (0)