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

temporalio / sdk-java / #181

pending completion
#181

push

github-actions

web-flow
Properly wrap exceptions from schedule client (#1827)

Wrap schedule exception

37 of 37 new or added lines in 1 file covered. (100.0%)

18557 of 23894 relevant lines covered (77.66%)

0.78 hits per line

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

46.88
/temporal-sdk/src/main/java/io/temporal/internal/sync/ExternalWorkflowStubImpl.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.internal.sync;
22

23
import io.temporal.api.common.v1.WorkflowExecution;
24
import io.temporal.common.interceptors.WorkflowOutboundCallsInterceptor;
25
import io.temporal.workflow.*;
26
import java.util.Objects;
27

28
/** Dynamic implementation of a strongly typed child workflow interface. */
29
class ExternalWorkflowStubImpl implements ExternalWorkflowStub {
30

31
  private final WorkflowOutboundCallsInterceptor outboundCallsInterceptor;
32
  private final WorkflowExecution execution;
33
  private Functions.Proc1<String> assertReadOnly;
34

35
  public ExternalWorkflowStubImpl(
36
      WorkflowExecution execution,
37
      WorkflowOutboundCallsInterceptor outboundCallsInterceptor,
38
      Functions.Proc1<String> assertReadOnly) {
1✔
39
    this.outboundCallsInterceptor = Objects.requireNonNull(outboundCallsInterceptor);
1✔
40
    this.execution = Objects.requireNonNull(execution);
1✔
41
    this.assertReadOnly = assertReadOnly;
1✔
42
  }
1✔
43

44
  @Override
45
  public WorkflowExecution getExecution() {
46
    return execution;
×
47
  }
48

49
  @Override
50
  public void signal(String signalName, Object... args) {
51
    assertReadOnly.apply("signal external workflow");
1✔
52
    Promise<Void> signaled =
1✔
53
        outboundCallsInterceptor
54
            .signalExternalWorkflow(
1✔
55
                new WorkflowOutboundCallsInterceptor.SignalExternalInput(
56
                    execution, signalName, args))
57
            .getResult();
1✔
58
    if (AsyncInternal.isAsync()) {
1✔
59
      AsyncInternal.setAsyncResult(signaled);
1✔
60
      return;
1✔
61
    }
62
    try {
63
      signaled.get();
1✔
64
    } catch (SignalExternalWorkflowException e) {
×
65
      // Reset stack to the current one. Otherwise it is very confusing to see a stack of
66
      // an event handling method.
67
      e.setStackTrace(Thread.currentThread().getStackTrace());
×
68
      throw e;
×
69
    }
1✔
70
  }
1✔
71

72
  @Override
73
  public void cancel() {
74
    assertReadOnly.apply("cancel external workflow");
×
75
    Promise<Void> cancelRequested =
×
76
        outboundCallsInterceptor
77
            .cancelWorkflow(new WorkflowOutboundCallsInterceptor.CancelWorkflowInput(execution))
×
78
            .getResult();
×
79
    if (AsyncInternal.isAsync()) {
×
80
      AsyncInternal.setAsyncResult(cancelRequested);
×
81
      return;
×
82
    }
83
    try {
84
      cancelRequested.get();
×
85
    } catch (CancelExternalWorkflowException e) {
×
86
      // Reset stack to the current one. Otherwise it is very confusing to see a stack of
87
      // an event handling method.
88
      e.setStackTrace(Thread.currentThread().getStackTrace());
×
89
      throw e;
×
90
    }
×
91
  }
×
92
}
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