• 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

93.18
/temporal-sdk/src/main/java/io/temporal/common/interceptors/WorkflowInboundCallsInterceptor.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.common.Experimental;
24
import javax.annotation.Nonnull;
25
import javax.annotation.Nullable;
26

27
/**
28
 * Intercepts inbound calls to the workflow execution on the worker side.
29
 *
30
 * <p>An instance should be created in {@link
31
 * WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor)}.
32
 *
33
 * <p>The calls to this interceptor are executed under workflow context, all the rules and
34
 * restrictions on the workflow code apply. See {@link io.temporal.workflow}.
35
 *
36
 * <p>Prefer extending {@link WorkflowInboundCallsInterceptorBase} and overriding only the methods
37
 * you need instead of implementing this interface directly. {@link
38
 * WorkflowInboundCallsInterceptorBase} provides correct default implementations to all the methods
39
 * of this interface.
40
 *
41
 * <p>The implementation must forward all the calls to {@code next}, but it may change the input
42
 * parameters.
43
 *
44
 * @see WorkerInterceptor#interceptWorkflow(WorkflowInboundCallsInterceptor) for a definition of
45
 *     "next" {@link WorkflowInboundCallsInterceptor}
46
 */
47
@Experimental
48
public interface WorkflowInboundCallsInterceptor {
49

50
  final class WorkflowInput {
51
    private final Header header;
52
    private final Object[] arguments;
53

54
    public WorkflowInput(Header header, Object[] arguments) {
1✔
55
      this.header = header;
1✔
56
      this.arguments = arguments;
1✔
57
    }
1✔
58

59
    public Header getHeader() {
60
      return header;
1✔
61
    }
62

63
    public Object[] getArguments() {
64
      return arguments;
1✔
65
    }
66
  }
67

68
  final class WorkflowOutput {
69
    private final Object result;
70

71
    public WorkflowOutput(Object result) {
1✔
72
      this.result = result;
1✔
73
    }
1✔
74

75
    public Object getResult() {
76
      return result;
1✔
77
    }
78
  }
79

80
  final class SignalInput {
81
    private final String signalName;
82
    private final Object[] arguments;
83
    private final long EventId;
84
    private final Header header;
85

86
    public SignalInput(String signalName, Object[] arguments, long eventId, Header header) {
1✔
87
      this.signalName = signalName;
1✔
88
      this.arguments = arguments;
1✔
89
      EventId = eventId;
1✔
90
      this.header = header;
1✔
91
    }
1✔
92

93
    public String getSignalName() {
94
      return signalName;
1✔
95
    }
96

97
    public Object[] getArguments() {
98
      return arguments;
1✔
99
    }
100

101
    public long getEventId() {
102
      return EventId;
×
103
    }
104

105
    public Header getHeader() {
106
      return header;
1✔
107
    }
108
  }
109

110
  final class QueryInput {
111
    private final String queryName;
112
    private final Header header;
113
    private final Object[] arguments;
114

115
    public QueryInput(String queryName, Header header, Object[] arguments) {
1✔
116
      this.queryName = queryName;
1✔
117
      this.header = header;
1✔
118
      this.arguments = arguments;
1✔
119
    }
1✔
120

121
    public String getQueryName() {
122
      return queryName;
1✔
123
    }
124

125
    public Header getHeader() {
126
      return header;
×
127
    }
128

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

134
  final class QueryOutput {
135
    private final Object result;
136

137
    public QueryOutput(Object result) {
1✔
138
      this.result = result;
1✔
139
    }
1✔
140

141
    public Object getResult() {
142
      return result;
1✔
143
    }
144
  }
145

146
  @Experimental
147
  final class UpdateInput {
148
    private final String updateName;
149
    private final Header header;
150
    private final Object[] arguments;
151

152
    public UpdateInput(String updateName, Header header, Object[] arguments) {
1✔
153
      this.updateName = updateName;
1✔
154
      this.header = header;
1✔
155
      this.arguments = arguments;
1✔
156
    }
1✔
157

158
    public String getUpdateName() {
159
      return updateName;
1✔
160
    }
161

162
    public Header getHeader() {
163
      return header;
×
164
    }
165

166
    public Object[] getArguments() {
167
      return arguments;
1✔
168
    }
169
  }
170

171
  @Experimental
172
  final class UpdateOutput {
173
    private final Object result;
174

175
    public UpdateOutput(Object result) {
1✔
176
      this.result = result;
1✔
177
    }
1✔
178

179
    public Object getResult() {
180
      return result;
1✔
181
    }
182
  }
183

184
  /**
185
   * Called when workflow class is instantiated. May create a {@link
186
   * WorkflowOutboundCallsInterceptor} instance. The instance must forward all the calls to {@code
187
   * outboundCalls}, but it may change the input parameters.
188
   *
189
   * <p>The instance should be passed into the {next.init(newWorkflowOutboundCallsInterceptor)}.
190
   *
191
   * @param outboundCalls an existing interceptor instance to be proxied by the interceptor created
192
   *     inside this method
193
   * @see WorkerInterceptor#interceptWorkflow for the definition of "next" {@link
194
   *     WorkflowInboundCallsInterceptor}
195
   */
196
  void init(WorkflowOutboundCallsInterceptor outboundCalls);
197

198
  /**
199
   * Called when workflow main method is called.
200
   *
201
   * @return result of the workflow execution.
202
   */
203
  WorkflowOutput execute(WorkflowInput input);
204

205
  /** Called when signal is delivered to a workflow execution. */
206
  void handleSignal(SignalInput input);
207

208
  /** Called when a workflow is queried. */
209
  QueryOutput handleQuery(QueryInput input);
210

211
  /**
212
   * Called when update workflow execution request is delivered to a workflow execution, before the
213
   * update is executed.
214
   */
215
  @Experimental
216
  void validateUpdate(UpdateInput input);
217

218
  /**
219
   * Called when update workflow execution request is delivered to a workflow execution, after
220
   * passing the validator.
221
   */
222
  @Experimental
223
  UpdateOutput executeUpdate(UpdateInput input);
224

225
  /**
226
   * Intercepts creation of the workflow main method thread
227
   *
228
   * @param runnable thread function to run
229
   * @param name name of the thread, optional
230
   * @return created workflow thread. Should be treated as a pass-through object that shouldn't be
231
   *     manipulated in any way by the interceptor code.
232
   */
233
  @Nonnull
234
  Object newWorkflowMethodThread(Runnable runnable, @Nullable String name);
235

236
  /**
237
   * Intercepts creation of a workflow callback thread
238
   *
239
   * @param runnable thread function to run
240
   * @param name name of the thread, optional
241
   * @return created workflow thread. Should be treated as a pass-through object that shouldn't be
242
   *     manipulated in any way by the interceptor code.
243
   */
244
  @Nonnull
245
  Object newCallbackThread(Runnable runnable, @Nullable String name);
246
}
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