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

temporalio / sdk-java / #188

25 Sep 2023 04:42PM UTC coverage: 77.369% (-0.3%) from 77.663%
#188

push

github-actions

web-flow
Fix null pointer on trigger immediately (#1865)

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

18670 of 24131 relevant lines covered (77.37%)

0.77 hits per line

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

48.48
/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.Header;
25
import io.temporal.common.interceptors.WorkflowOutboundCallsInterceptor;
26
import io.temporal.workflow.*;
27
import java.util.Objects;
28

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

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

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

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

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

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