• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #427

16 Nov 2026 04:17PM UTC coverage: 71.787% (+0.1%) from 71.675%
#427

push

github

web-flow
Provide the namespace to storage drivers (#3203)

8613 of 14069 branches covered (61.22%)

Branch coverage included in aggregate %.

13 of 22 new or added lines in 12 files covered. (59.09%)

140 existing lines in 13 files now uncovered.

34118 of 45456 relevant lines covered (75.06%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

49.15
/temporal-sdk/src/main/java/io/temporal/client/NexusClientImpl.java
1
package io.temporal.client;
2

3
import static io.temporal.internal.WorkflowThreadMarker.enforceNonWorkflowThread;
4

5
import com.uber.m3.tally.Scope;
6
import io.temporal.common.Experimental;
7
import io.temporal.common.interceptors.NexusClientCallsInterceptor;
8
import io.temporal.common.interceptors.NexusClientCallsInterceptor.CountNexusOperationExecutionsInput;
9
import io.temporal.common.interceptors.NexusClientCallsInterceptor.CountNexusOperationExecutionsOutput;
10
import io.temporal.common.interceptors.NexusClientCallsInterceptor.ListNexusOperationExecutionsInput;
11
import io.temporal.common.interceptors.NexusClientCallsInterceptor.ListNexusOperationExecutionsOutput;
12
import io.temporal.common.interceptors.NexusClientInterceptor;
13
import io.temporal.internal.WorkflowThreadMarker;
14
import io.temporal.internal.client.ClientDataConverterFactory;
15
import io.temporal.internal.client.NamespaceInjectWorkflowServiceStubs;
16
import io.temporal.internal.client.NexusClientResolvedOptions;
17
import io.temporal.internal.client.NexusOperationHandleImpl;
18
import io.temporal.internal.client.RootNexusClientInvoker;
19
import io.temporal.internal.client.external.GenericWorkflowClient;
20
import io.temporal.internal.client.external.GenericWorkflowClientImpl;
21
import io.temporal.internal.payload.storage.ExternalStorageRunner;
22
import io.temporal.serviceclient.MetricsTag;
23
import io.temporal.serviceclient.WorkflowServiceStubs;
24
import java.util.List;
25
import java.util.stream.Stream;
26
import javax.annotation.Nullable;
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

30
@Experimental
31
public class NexusClientImpl implements NexusClient {
32

33
  private static final Logger log = LoggerFactory.getLogger(NexusClientImpl.class);
1 ✔
34

35
  private final WorkflowServiceStubs workflowServiceStubs;
36
  private final NexusClientResolvedOptions options;
37
  private final GenericWorkflowClient genericClient;
38
  private final Scope metricsScope;
39
  private final NexusClientCallsInterceptor nexusClientCallsInvoker;
40
  private final List<NexusClientInterceptor> interceptors;
41

42
  public static NexusClient newInstance(WorkflowServiceStubs service, NexusClientOptions options) {
43
    enforceNonWorkflowThread();
1 ✔
44
    return WorkflowThreadMarker.protectFromWorkflowThread(
1 ✔
45
        new NexusClientImpl(service, options), NexusClient.class);
46
  }
47

48
  NexusClientImpl(WorkflowServiceStubs workflowServiceStubs, NexusClientOptions clientOptions) {
1 ✔
49
    NexusClientResolvedOptions options =
1 ✔
50
        clientOptions.toResolvedOptions(
1 ✔
51
            clientOptions.getExternalStorage() == null
1 !
52
                ? ClientDataConverterFactory.forClient(clientOptions.getDataConverter())
1 ✔
53
                : ClientDataConverterFactory.forClient(
×
54
                    clientOptions.getDataConverter(),
×
NEW
55
                    ExternalStorageRunner.create(
×
NEW
56
                        clientOptions.getExternalStorage(), clientOptions.getNamespace())));
×
57
    workflowServiceStubs =
1 ✔
58
        new NamespaceInjectWorkflowServiceStubs(workflowServiceStubs, options.getNamespace());
1 ✔
59
    this.workflowServiceStubs = workflowServiceStubs;
1 ✔
60
    this.options = options;
1 ✔
61
    this.metricsScope =
1 ✔
62
        workflowServiceStubs
63
            .getOptions()
1 ✔
64
            .getMetricsScope()
1 ✔
65
            .tagged(MetricsTag.defaultTags(options.getNamespace()));
1 ✔
66
    this.genericClient = new GenericWorkflowClientImpl(workflowServiceStubs, metricsScope);
1 ✔
67
    this.interceptors = options.getInterceptors();
1 ✔
68
    this.nexusClientCallsInvoker = initializeClientInvoker();
1 ✔
69
    if (log.isDebugEnabled()) {
1 !
70
      log.debug(
×
71
          "NexusClient initialized: namespace={}, interceptors={}",
72
          options.getNamespace(),
×
73
          interceptors.size());
×
74
    }
75
  }
1 ✔
76

77
  private NexusClientCallsInterceptor initializeClientInvoker() {
78
    NexusClientCallsInterceptor invoker = new RootNexusClientInvoker(genericClient, options);
1 ✔
79
    for (NexusClientInterceptor clientInterceptor : interceptors) {
1 !
80
      NexusClientCallsInterceptor wrapped = clientInterceptor.nexusClientCallsInterceptor(invoker);
×
81
      if (wrapped == null) {
×
82
        throw new IllegalStateException(
×
83
            "NexusClientInterceptor "
84
                + clientInterceptor.getClass().getName()
×
85
                + " returned null from nexusClientCallsInterceptor; expected a non-null"
86
                + " NexusClientCallsInterceptor wrapping the supplied next link");
87
      }
88
      invoker = wrapped;
×
89
    }
×
90
    return invoker;
1 ✔
91
  }
92

93
  @Override
94
  public WorkflowServiceStubs getWorkflowServiceStubs() {
95
    return workflowServiceStubs;
×
96
  }
97

98
  @Override
99
  public UntypedNexusOperationHandle getHandle(String operationId, @Nullable String runId) {
100
    return new NexusOperationHandleImpl(operationId, runId, nexusClientCallsInvoker);
×
101
  }
102

103
  @Override
104
  public <R> NexusOperationHandle<R> getHandle(
105
      String operationId, @Nullable String runId, Class<R> resultClass) {
106
    return getHandle(operationId, runId, resultClass, null);
×
107
  }
108

109
  @Override
110
  public <R> NexusOperationHandle<R> getHandle(
111
      String operationId,
112
      @Nullable String runId,
113
      Class<R> resultClass,
114
      @Nullable java.lang.reflect.Type resultType) {
115
    return NexusOperationHandle.fromUntyped(getHandle(operationId, runId), resultClass, resultType);
×
116
  }
117

118
  @Override
119
  public <T> NexusServiceClient<T> newNexusServiceClient(Class<T> service, String endpoint) {
120
    enforceNonWorkflowThread();
×
121
    return WorkflowThreadMarker.protectFromWorkflowThread(
×
122
        new NexusServiceClientImpl<>(nexusClientCallsInvoker, service, endpoint, options),
123
        NexusServiceClient.class);
124
  }
125

126
  @Override
127
  public UntypedNexusServiceClient newUntypedNexusServiceClient(
128
      String endpoint, String serviceName) {
129
    enforceNonWorkflowThread();
1 ✔
130
    return WorkflowThreadMarker.protectFromWorkflowThread(
1 ✔
131
        new UntypedNexusServiceClientImpl(nexusClientCallsInvoker, endpoint, serviceName, options),
132
        UntypedNexusServiceClient.class);
133
  }
134

135
  @Override
136
  public Stream<NexusOperationExecutionMetadata> listNexusOperationExecutions(
137
      @Nullable String query) {
138
    ListNexusOperationExecutionsOutput out =
×
139
        nexusClientCallsInvoker.listNexusOperationExecutions(
×
140
            new ListNexusOperationExecutionsInput(query));
141
    return out.getOperations();
×
142
  }
143

144
  @Override
145
  public NexusOperationExecutionCount countNexusOperationExecutions(@Nullable String query) {
146
    CountNexusOperationExecutionsOutput out =
×
147
        nexusClientCallsInvoker.countNexusOperationExecutions(
×
148
            new CountNexusOperationExecutionsInput(query));
149
    return out.getCount();
×
150
  }
151
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc