Skip to content

Commit c4d4af8

Browse files
Make sure tracing interceptor is applied first
1 parent 3d9f09c commit c4d4af8

3 files changed

Lines changed: 8 additions & 29 deletions

File tree

temporal-spring-boot-autoconfigure/src/main/java/io/temporal/spring/boot/autoconfigure/template/WorkerFactoryOptionsTemplate.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io.temporal.spring.boot.autoconfigure.properties.NamespaceProperties;
99
import io.temporal.worker.WorkerFactoryOptions;
1010
import java.util.ArrayList;
11-
import java.util.Collections;
1211
import java.util.List;
1312
import java.util.Optional;
1413
import javax.annotation.Nonnull;
@@ -45,14 +44,16 @@ public WorkerFactoryOptions createWorkerFactoryOptions() {
4544
.ifPresent(options::setUsingVirtualWorkflowThreads);
4645
}
4746

48-
List<WorkerInterceptor> interceptors =
49-
new ArrayList<>(workerInterceptors != null ? workerInterceptors : Collections.EMPTY_LIST);
47+
List<WorkerInterceptor> interceptors = new ArrayList<>();
5048
if (tracer != null) {
5149
OpenTracingWorkerInterceptor openTracingClientInterceptor =
5250
new OpenTracingWorkerInterceptor(
5351
OpenTracingOptions.newBuilder().setTracer(tracer).build());
5452
interceptors.add(openTracingClientInterceptor);
5553
}
54+
if (workerInterceptors != null) {
55+
interceptors.addAll(workerInterceptors);
56+
}
5657
options.setWorkerInterceptors(interceptors.stream().toArray(WorkerInterceptor[]::new));
5758

5859
if (customizer != null) {

temporal-spring-boot-autoconfigure/src/main/java/io/temporal/spring/boot/autoconfigure/template/WorkflowClientOptionsTemplate.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import io.temporal.opentracing.OpenTracingOptions;
1111
import io.temporal.spring.boot.TemporalOptionsCustomizer;
1212
import java.util.ArrayList;
13-
import java.util.Collections;
1413
import java.util.List;
1514
import java.util.Optional;
1615
import javax.annotation.Nonnull;
@@ -48,17 +47,16 @@ public WorkflowClientOptions createWorkflowClientOptions() {
4847
options.setNamespace(namespace);
4948
Optional.ofNullable(dataConverter).ifPresent(options::setDataConverter);
5049

51-
List<WorkflowClientInterceptor> interceptors =
52-
new ArrayList<>(
53-
workflowClientInterceptors != null
54-
? workflowClientInterceptors
55-
: Collections.EMPTY_LIST);
50+
List<WorkflowClientInterceptor> interceptors = new ArrayList<>();
5651
if (tracer != null) {
5752
OpenTracingClientInterceptor openTracingClientInterceptor =
5853
new OpenTracingClientInterceptor(
5954
OpenTracingOptions.newBuilder().setTracer(tracer).build());
6055
interceptors.add(openTracingClientInterceptor);
6156
}
57+
if (workflowClientInterceptors != null) {
58+
interceptors.addAll(workflowClientInterceptors);
59+
}
6260

6361
options.setInterceptors(interceptors.stream().toArray(WorkflowClientInterceptor[]::new));
6462

temporal-spring-boot-autoconfigure/src/test/java/io/temporal/spring/boot/autoconfigure/InterceptorsTest.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
/*
2-
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3-
*
4-
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5-
*
6-
* Modifications copyright (C) 2017 Uber Technologies, Inc.
7-
*
8-
* Licensed under the Apache License, Version 2.0 (the "License");
9-
* you may not use this material except in compliance with the License.
10-
* You may obtain a copy of the License at
11-
*
12-
* http://www.apache.org/licenses/LICENSE-2.0
13-
*
14-
* Unless required by applicable law or agreed to in writing, software
15-
* distributed under the License is distributed on an "AS IS" BASIS,
16-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17-
* See the License for the specific language governing permissions and
18-
* limitations under the License.
19-
*/
20-
211
package io.temporal.spring.boot.autoconfigure;
222

233
import static org.mockito.ArgumentMatchers.any;

0 commit comments

Comments
 (0)