1919
2020package io .temporal .serviceclient ;
2121
22- import com .google .common .collect .ImmutableMap ;
2322import com .uber .m3 .tally .NoopScope ;
2423import com .uber .m3 .tally .Scope ;
2524import io .grpc .ManagedChannel ;
2625import io .grpc .ManagedChannelBuilder ;
26+ import io .grpc .Metadata ;
2727import io .grpc .NameResolver ;
2828import io .grpc .netty .shaded .io .netty .handler .ssl .SslContext ;
2929import io .temporal .api .workflowservice .v1 .WorkflowServiceGrpc ;
3030import java .time .Duration ;
31- import java .util .Map ;
3231import java .util .Objects ;
3332import java .util .Optional ;
3433import java .util .function .Function ;
@@ -87,7 +86,7 @@ public static WorkflowServiceStubsOptions getDefaultInstance() {
8786 private final Duration connectionBackoffResetFrequency ;
8887
8988 /** Optional gRPC headers */
90- private final Map < String , String > headers ;
89+ private final Metadata headers ;
9190
9291 private final Scope metricsScope ;
9392
@@ -143,8 +142,11 @@ private WorkflowServiceStubsOptions(Builder builder, boolean ignore) {
143142 this .connectionBackoffResetFrequency = builder .connectionBackoffResetFrequency ;
144143 this .blockingStubInterceptor = builder .blockingStubInterceptor ;
145144 this .futureStubInterceptor = builder .futureStubInterceptor ;
146- this .headers =
147- builder .headers == null ? ImmutableMap .of () : ImmutableMap .copyOf (builder .headers );
145+ if (builder .headers != null ) {
146+ this .headers = builder .headers ;
147+ } else {
148+ this .headers = new Metadata ();
149+ }
148150 this .metricsScope = builder .metricsScope == null ? new NoopScope () : builder .metricsScope ;
149151 }
150152
@@ -189,7 +191,7 @@ public Duration getConnectionBackoffResetFrequency() {
189191 return connectionBackoffResetFrequency ;
190192 }
191193
192- public Map < String , String > getHeaders () {
194+ public Metadata getHeaders () {
193195 return headers ;
194196 }
195197
@@ -219,6 +221,7 @@ public Scope getMetricsScope() {
219221 * @author venkat
220222 */
221223 public static class Builder {
224+
222225 private ManagedChannel channel ;
223226 private SslContext sslContext ;
224227 private boolean enableHttps ;
@@ -227,7 +230,7 @@ public static class Builder {
227230 private Duration rpcLongPollTimeout = DEFAULT_POLL_RPC_TIMEOUT ;
228231 private Duration rpcQueryTimeout = DEFAULT_QUERY_RPC_TIMEOUT ;
229232 private Duration connectionBackoffResetFrequency = DEFAULT_CONNECTION_BACKOFF_RESET_FREQUENCY ;
230- private Map < String , String > headers ;
233+ private Metadata headers ;
231234 private Function <
232235 WorkflowServiceGrpc .WorkflowServiceBlockingStub ,
233236 WorkflowServiceGrpc .WorkflowServiceBlockingStub >
@@ -330,7 +333,7 @@ public Builder setQueryRpcTimeout(Duration timeout) {
330333 return this ;
331334 }
332335
333- public Builder setHeaders (Map < String , String > headers ) {
336+ public Builder setHeaders (Metadata headers ) {
334337 this .headers = headers ;
335338 return this ;
336339 }
0 commit comments