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

temporalio / sdk-java / #172

pending completion
#172

push

github-actions

web-flow
Update CODEOWNERS (#1773)

## What was changed
Update CODEOWNERS so that Security can own the Semgrep rules files and paths.

## Why?
We are adding Semgrep for static analysis to this repository, and only the security team should be able to approve exclusions from the policy.

## Checklist

How was this tested:
We ran this scanner on internal repos with this CODEOWNERS file and it worked as expected.

18029 of 22084 relevant lines covered (81.64%)

0.82 hits per line

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

96.48
/temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowClientCallsInterceptor.java
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

21
package io.temporal.common.interceptors;
22

23
import io.temporal.api.common.v1.WorkflowExecution;
24
import io.temporal.api.enums.v1.WorkflowExecutionStatus;
25
import io.temporal.api.update.v1.UpdateRef;
26
import io.temporal.api.update.v1.WaitPolicy;
27
import io.temporal.client.WorkflowOptions;
28
import io.temporal.common.Experimental;
29
import java.lang.reflect.Type;
30
import java.util.Optional;
31
import java.util.concurrent.CompletableFuture;
32
import java.util.concurrent.TimeUnit;
33
import java.util.concurrent.TimeoutException;
34
import javax.annotation.Nonnull;
35
import javax.annotation.Nullable;
36

37
/**
38
 * Intercepts calls to the {@link io.temporal.client.WorkflowClient} related to the lifecycle of a
39
 * Workflow.
40
 *
41
 * <p>Prefer extending {@link WorkflowClientCallsInterceptorBase} and overriding only the methods
42
 * you need instead of implementing this interface directly. {@link
43
 * WorkflowClientCallsInterceptorBase} provides correct default implementations to all the methods
44
 * of this interface.
45
 */
46
@Experimental
47
public interface WorkflowClientCallsInterceptor {
48
  /**
49
   * If you implement this method, {@link #signalWithStart} most likely needs to be implemented too.
50
   *
51
   * @see #signalWithStart
52
   */
53
  WorkflowStartOutput start(WorkflowStartInput input);
54

55
  /**
56
   * If you implement this method, {@link #signalWithStart} most likely needs to be implemented too.
57
   *
58
   * @see #signalWithStart
59
   */
60
  WorkflowSignalOutput signal(WorkflowSignalInput input);
61

62
  WorkflowSignalWithStartOutput signalWithStart(WorkflowSignalWithStartInput input);
63

64
  /**
65
   * If you implement this method, {@link #getResultAsync} most likely needs to be implemented too.
66
   *
67
   * @see #getResultAsync
68
   */
69
  <R> GetResultOutput<R> getResult(GetResultInput<R> input) throws TimeoutException;
70

71
  /**
72
   * If you implement this method, {@link #getResult} most likely needs to be implemented too.
73
   *
74
   * @see #getResult
75
   */
76
  <R> GetResultAsyncOutput<R> getResultAsync(GetResultInput<R> input);
77

78
  <R> QueryOutput<R> query(QueryInput<R> input);
79

80
  @Experimental
81
  <R> StartUpdateOutput<R> startUpdate(StartUpdateInput<R> input);
82

83
  @Experimental
84
  <R> PollWorkflowUpdateOutput<R> pollWorkflowUpdate(PollWorkflowUpdateInput<R> input);
85

86
  CancelOutput cancel(CancelInput input);
87

88
  TerminateOutput terminate(TerminateInput input);
89

90
  final class WorkflowStartInput {
91
    private final String workflowId;
92
    private final String workflowType;
93
    private final Header header;
94
    private final Object[] arguments;
95
    private final WorkflowOptions options;
96

97
    /**
98
     * @param workflowId id of the workflow to be started
99
     * @param workflowType workflow type name
100
     * @param header internal Temporal header that is used to pass context between different
101
     *     abstractions and actors
102
     * @param arguments input arguments for the workflow
103
     * @param options workflow options
104
     */
105
    public WorkflowStartInput(
106
        @Nonnull String workflowId,
107
        @Nonnull String workflowType,
108
        @Nonnull Header header,
109
        @Nonnull Object[] arguments,
110
        @Nonnull WorkflowOptions options) {
1✔
111
      this.workflowId = workflowId;
1✔
112
      this.workflowType = workflowType;
1✔
113
      this.header = header;
1✔
114
      this.arguments = arguments;
1✔
115
      this.options = options;
1✔
116
    }
1✔
117

118
    public String getWorkflowId() {
119
      return workflowId;
1✔
120
    }
121

122
    public String getWorkflowType() {
123
      return workflowType;
1✔
124
    }
125

126
    public Header getHeader() {
127
      return header;
1✔
128
    }
129

130
    public Object[] getArguments() {
131
      return arguments;
1✔
132
    }
133

134
    public WorkflowOptions getOptions() {
135
      return options;
1✔
136
    }
137
  }
138

139
  final class WorkflowStartOutput {
140
    private final @Nonnull WorkflowExecution workflowExecution;
141

142
    public WorkflowStartOutput(@Nonnull WorkflowExecution workflowExecution) {
1✔
143
      this.workflowExecution = workflowExecution;
1✔
144
    }
1✔
145

146
    @Nonnull
147
    public WorkflowExecution getWorkflowExecution() {
148
      return workflowExecution;
1✔
149
    }
150
  }
151

152
  final class WorkflowSignalInput {
153
    private final WorkflowExecution workflowExecution;
154
    private final String signalName;
155
    private final Object[] arguments;
156

157
    public WorkflowSignalInput(
158
        WorkflowExecution workflowExecution, String signalName, Object[] signalArguments) {
1✔
159
      this.workflowExecution = workflowExecution;
1✔
160
      this.signalName = signalName;
1✔
161
      this.arguments = signalArguments;
1✔
162
    }
1✔
163

164
    public WorkflowExecution getWorkflowExecution() {
165
      return workflowExecution;
1✔
166
    }
167

168
    public String getSignalName() {
169
      return signalName;
1✔
170
    }
171

172
    public Object[] getArguments() {
173
      return arguments;
1✔
174
    }
175
  }
176

177
  final class WorkflowSignalOutput {}
1✔
178

179
  final class WorkflowSignalWithStartInput {
180
    private final WorkflowStartInput workflowStartInput;
181
    private final String signalName;
182
    private final Object[] signalArguments;
183

184
    public WorkflowSignalWithStartInput(
185
        WorkflowStartInput workflowStartInput, String signalName, Object[] signalArguments) {
1✔
186
      this.workflowStartInput = workflowStartInput;
1✔
187
      this.signalName = signalName;
1✔
188
      this.signalArguments = signalArguments;
1✔
189
    }
1✔
190

191
    public WorkflowStartInput getWorkflowStartInput() {
192
      return workflowStartInput;
1✔
193
    }
194

195
    public String getSignalName() {
196
      return signalName;
1✔
197
    }
198

199
    public Object[] getSignalArguments() {
200
      return signalArguments;
1✔
201
    }
202
  }
203

204
  final class WorkflowSignalWithStartOutput {
205
    private final WorkflowStartOutput workflowStartOutput;
206

207
    public WorkflowSignalWithStartOutput(WorkflowStartOutput workflowStartOutput) {
1✔
208
      this.workflowStartOutput = workflowStartOutput;
1✔
209
    }
1✔
210

211
    public WorkflowStartOutput getWorkflowStartOutput() {
212
      return workflowStartOutput;
1✔
213
    }
214
  }
215

216
  final class GetResultInput<R> {
217
    private final WorkflowExecution workflowExecution;
218
    private final Optional<String> workflowType;
219
    private final long timeout;
220
    private final TimeUnit timeoutUnit;
221
    private final Class<R> resultClass;
222
    private final Type resultType;
223

224
    public GetResultInput(
225
        WorkflowExecution workflowExecution,
226
        Optional<String> workflowType,
227
        long timeout,
228
        TimeUnit timeoutUnit,
229
        Class<R> resultClass,
230
        Type resultType) {
1✔
231
      this.workflowExecution = workflowExecution;
1✔
232
      this.workflowType = workflowType;
1✔
233
      this.timeout = timeout;
1✔
234
      this.timeoutUnit = timeoutUnit;
1✔
235
      this.resultClass = resultClass;
1✔
236
      this.resultType = resultType;
1✔
237
    }
1✔
238

239
    public WorkflowExecution getWorkflowExecution() {
240
      return workflowExecution;
1✔
241
    }
242

243
    public Optional<String> getWorkflowType() {
244
      return workflowType;
1✔
245
    }
246

247
    public long getTimeout() {
248
      return timeout;
1✔
249
    }
250

251
    public TimeUnit getTimeoutUnit() {
252
      return timeoutUnit;
1✔
253
    }
254

255
    public Class<R> getResultClass() {
256
      return resultClass;
1✔
257
    }
258

259
    public Type getResultType() {
260
      return resultType;
1✔
261
    }
262
  }
263

264
  final class GetResultOutput<R> {
265
    private final R result;
266

267
    public GetResultOutput(R result) {
1✔
268
      this.result = result;
1✔
269
    }
1✔
270

271
    public R getResult() {
272
      return result;
1✔
273
    }
274
  }
275

276
  final class GetResultAsyncOutput<R> {
277
    private final CompletableFuture<R> result;
278

279
    public GetResultAsyncOutput(CompletableFuture<R> result) {
1✔
280
      this.result = result;
1✔
281
    }
1✔
282

283
    public CompletableFuture<R> getResult() {
284
      return result;
1✔
285
    }
286
  }
287

288
  final class QueryInput<R> {
289
    private final WorkflowExecution workflowExecution;
290
    private final String queryType;
291
    private final Object[] arguments;
292
    private final Class<R> resultClass;
293
    private final Type resultType;
294

295
    public QueryInput(
296
        WorkflowExecution workflowExecution,
297
        String queryType,
298
        Object[] arguments,
299
        Class<R> resultClass,
300
        Type resultType) {
1✔
301
      this.workflowExecution = workflowExecution;
1✔
302
      this.queryType = queryType;
1✔
303
      this.arguments = arguments;
1✔
304
      this.resultClass = resultClass;
1✔
305
      this.resultType = resultType;
1✔
306
    }
1✔
307

308
    public WorkflowExecution getWorkflowExecution() {
309
      return workflowExecution;
1✔
310
    }
311

312
    public String getQueryType() {
313
      return queryType;
1✔
314
    }
315

316
    public Object[] getArguments() {
317
      return arguments;
1✔
318
    }
319

320
    public Class<R> getResultClass() {
321
      return resultClass;
1✔
322
    }
323

324
    public Type getResultType() {
325
      return resultType;
1✔
326
    }
327
  }
328

329
  final class QueryOutput<R> {
330
    private final WorkflowExecutionStatus queryRejectedStatus;
331
    private final R result;
332

333
    /**
334
     * @param queryRejectedStatus should be null if query is not rejected
335
     * @param result converted result value
336
     */
337
    public QueryOutput(WorkflowExecutionStatus queryRejectedStatus, R result) {
1✔
338
      this.queryRejectedStatus = queryRejectedStatus;
1✔
339
      this.result = result;
1✔
340
    }
1✔
341

342
    public boolean isQueryRejected() {
343
      return queryRejectedStatus != null;
1✔
344
    }
345

346
    public WorkflowExecutionStatus getQueryRejectedStatus() {
347
      return queryRejectedStatus;
1✔
348
    }
349

350
    public R getResult() {
351
      return result;
1✔
352
    }
353
  }
354

355
  final class CancelInput {
356
    private final WorkflowExecution workflowExecution;
357

358
    public CancelInput(WorkflowExecution workflowExecution) {
1✔
359
      this.workflowExecution = workflowExecution;
1✔
360
    }
1✔
361

362
    public WorkflowExecution getWorkflowExecution() {
363
      return workflowExecution;
1✔
364
    }
365
  }
366

367
  @Experimental
368
  final class StartUpdateInput<R> {
369
    private final WorkflowExecution workflowExecution;
370
    private final String updateName;
371
    private final Object[] arguments;
372
    private final Class<R> resultClass;
373
    private final Type resultType;
374
    private final String updateId;
375
    private final String firstExecutionRunId;
376
    private final WaitPolicy waitPolicy;
377

378
    public StartUpdateInput(
379
        WorkflowExecution workflowExecution,
380
        String updateName,
381
        String updateId,
382
        Object[] arguments,
383
        Class<R> resultClass,
384
        Type resultType,
385
        String firstExecutionRunId,
386
        WaitPolicy waitPolicy) {
1✔
387
      this.workflowExecution = workflowExecution;
1✔
388
      this.updateId = updateId;
1✔
389
      this.updateName = updateName;
1✔
390
      this.arguments = arguments;
1✔
391
      this.resultClass = resultClass;
1✔
392
      this.resultType = resultType;
1✔
393
      this.firstExecutionRunId = firstExecutionRunId;
1✔
394
      this.waitPolicy = waitPolicy;
1✔
395
    }
1✔
396

397
    public WorkflowExecution getWorkflowExecution() {
398
      return workflowExecution;
1✔
399
    }
400

401
    public String getUpdateName() {
402
      return updateName;
1✔
403
    }
404

405
    public String getUpdateId() {
406
      return updateId;
1✔
407
    }
408

409
    public Object[] getArguments() {
410
      return arguments;
1✔
411
    }
412

413
    public Class<R> getResultClass() {
414
      return resultClass;
1✔
415
    }
416

417
    public Type getResultType() {
418
      return resultType;
1✔
419
    }
420

421
    public String getFirstExecutionRunId() {
422
      return firstExecutionRunId;
1✔
423
    }
424

425
    public WaitPolicy getWaitPolicy() {
426
      return waitPolicy;
1✔
427
    }
428
  }
429

430
  @Experimental
431
  final class UpdateOutput<R> {
432
    private final R result;
433

434
    public UpdateOutput(R result) {
×
435
      this.result = result;
×
436
    }
×
437

438
    public R getResult() {
439
      return result;
×
440
    }
441
  }
442

443
  @Experimental
444
  final class StartUpdateOutput<R> {
445
    private final UpdateRef reference;
446
    private final R result;
447
    private final boolean hasResult;
448

449
    public StartUpdateOutput(UpdateRef reference, boolean hasResult, R result) {
1✔
450
      this.reference = reference;
1✔
451
      this.result = result;
1✔
452
      this.hasResult = hasResult;
1✔
453
    }
1✔
454

455
    public UpdateRef getReference() {
456
      return reference;
1✔
457
    }
458

459
    public boolean hasResult() {
460
      return hasResult;
1✔
461
    }
462

463
    public R getResult() {
464
      return result;
1✔
465
    }
466
  }
467

468
  @Experimental
469
  final class PollWorkflowUpdateInput<R> {
470
    private final WorkflowExecution workflowExecution;
471
    private long timeout;
472
    private TimeUnit timeoutUnit;
473
    private final Class<R> resultClass;
474
    private final Type resultType;
475
    private final String updateName;
476
    private final String updateId;
477

478
    public PollWorkflowUpdateInput(
479
        WorkflowExecution workflowExecution,
480
        String updateName,
481
        String updateId,
482
        Class<R> resultClass,
483
        Type resultType,
484
        long timeout,
485
        TimeUnit timeoutUnit) {
1✔
486
      this.workflowExecution = workflowExecution;
1✔
487
      this.updateName = updateName;
1✔
488
      this.updateId = updateId;
1✔
489
      this.resultClass = resultClass;
1✔
490
      this.resultType = resultType;
1✔
491
      this.timeout = timeout;
1✔
492
      this.timeoutUnit = timeoutUnit;
1✔
493
    }
1✔
494

495
    public WorkflowExecution getWorkflowExecution() {
496
      return workflowExecution;
1✔
497
    }
498

499
    public long getTimeout() {
500
      return timeout;
1✔
501
    }
502

503
    public TimeUnit getTimeoutUnit() {
504
      return timeoutUnit;
1✔
505
    }
506

507
    public Class<R> getResultClass() {
508
      return resultClass;
1✔
509
    }
510

511
    public Type getResultType() {
512
      return resultType;
1✔
513
    }
514

515
    public String getUpdateName() {
516
      return updateName;
×
517
    }
518

519
    public String getUpdateId() {
520
      return updateId;
1✔
521
    }
522
  }
523

524
  @Experimental
525
  final class PollWorkflowUpdateOutput<R> {
526
    private final CompletableFuture<R> result;
527

528
    public PollWorkflowUpdateOutput(CompletableFuture<R> result) {
1✔
529
      this.result = result;
1✔
530
    }
1✔
531

532
    public CompletableFuture<R> getResult() {
533
      return result;
1✔
534
    }
535
  }
536

537
  final class CancelOutput {}
1✔
538

539
  final class TerminateInput {
540
    private final WorkflowExecution workflowExecution;
541
    private final @Nullable String reason;
542
    private final Object[] details;
543

544
    public TerminateInput(
545
        WorkflowExecution workflowExecution, @Nullable String reason, Object[] details) {
1✔
546
      this.workflowExecution = workflowExecution;
1✔
547
      this.reason = reason;
1✔
548
      this.details = details;
1✔
549
    }
1✔
550

551
    public WorkflowExecution getWorkflowExecution() {
552
      return workflowExecution;
1✔
553
    }
554

555
    @Nullable
556
    public String getReason() {
557
      return reason;
1✔
558
    }
559

560
    public Object[] getDetails() {
561
      return details;
1✔
562
    }
563
  }
564

565
  final class TerminateOutput {}
1✔
566
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc