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

temporalio / sdk-java / #213

17 Nov 2023 09:10PM CUT coverage: 77.268% (-0.06%) from 77.33%
#213

push

github

web-flow
Delete .github/workflows/semgrep.yml (#1934)

* Delete .github/workflows/semgrep.yml

* Update CODEOWNERS

18739 of 24252 relevant lines covered (77.27%)

0.77 hits per line

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

26.83
/temporal-sdk/src/main/java/io/temporal/client/ActivityCompletionClientImpl.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.client;
22

23
import com.uber.m3.tally.Scope;
24
import io.temporal.api.common.v1.WorkflowExecution;
25
import io.temporal.internal.client.external.ManualActivityCompletionClientFactory;
26
import io.temporal.payload.context.ActivitySerializationContext;
27
import io.temporal.workflow.Functions;
28
import java.util.Optional;
29
import javax.annotation.Nonnull;
30
import javax.annotation.Nullable;
31

32
class ActivityCompletionClientImpl implements ActivityCompletionClient {
33

34
  private final ManualActivityCompletionClientFactory factory;
35
  private final Functions.Proc completionHandle;
36
  private final Scope metricsScope;
37
  private final @Nullable ActivitySerializationContext serializationContext;
38

39
  ActivityCompletionClientImpl(
40
      ManualActivityCompletionClientFactory manualActivityCompletionClientFactory,
41
      Functions.Proc completionHandle,
42
      Scope metricsScope,
43
      @Nullable ActivitySerializationContext serializationContext) {
1✔
44
    this.factory = manualActivityCompletionClientFactory;
1✔
45
    this.completionHandle = completionHandle;
1✔
46
    this.metricsScope = metricsScope;
1✔
47
    this.serializationContext = serializationContext;
1✔
48
  }
1✔
49

50
  @Override
51
  public <R> void complete(byte[] taskToken, R result) {
52
    try {
53
      factory.getClient(taskToken, metricsScope, serializationContext).complete(result);
1✔
54
    } finally {
55
      completionHandle.apply();
1✔
56
    }
57
  }
1✔
58

59
  @Override
60
  public <R> void complete(String workflowId, Optional<String> runId, String activityId, R result) {
61
    try {
62
      factory
×
63
          .getClient(toExecution(workflowId, runId), activityId, metricsScope, serializationContext)
×
64
          .complete(result);
×
65
    } finally {
66
      completionHandle.apply();
×
67
    }
68
  }
×
69

70
  @Override
71
  public void completeExceptionally(byte[] taskToken, Exception result) {
72
    try {
73
      factory.getClient(taskToken, metricsScope, serializationContext).fail(result);
×
74
    } finally {
75
      completionHandle.apply();
×
76
    }
77
  }
×
78

79
  @Override
80
  public void completeExceptionally(
81
      String workflowId, Optional<String> runId, String activityId, Exception result) {
82
    try {
83
      factory
×
84
          .getClient(toExecution(workflowId, runId), activityId, metricsScope, serializationContext)
×
85
          .fail(result);
×
86
    } finally {
87
      completionHandle.apply();
×
88
    }
89
  }
×
90

91
  @Override
92
  public <V> void reportCancellation(byte[] taskToken, V details) {
93
    try {
94
      factory.getClient(taskToken, metricsScope, serializationContext).reportCancellation(details);
×
95
    } finally {
96
      completionHandle.apply();
×
97
    }
98
  }
×
99

100
  @Override
101
  public <V> void reportCancellation(
102
      String workflowId, Optional<String> runId, String activityId, V details) {
103
    try {
104
      factory
×
105
          .getClient(toExecution(workflowId, runId), activityId, metricsScope, serializationContext)
×
106
          .reportCancellation(details);
×
107
    } finally {
108
      completionHandle.apply();
×
109
    }
110
  }
×
111

112
  @Override
113
  public <V> void heartbeat(byte[] taskToken, V details) throws ActivityCompletionException {
114
    factory.getClient(taskToken, metricsScope).recordHeartbeat(details);
1✔
115
  }
1✔
116

117
  @Override
118
  public <V> void heartbeat(String workflowId, Optional<String> runId, String activityId, V details)
119
      throws ActivityCompletionException {
120
    factory
×
121
        .getClient(toExecution(workflowId, runId), activityId, metricsScope, serializationContext)
×
122
        .recordHeartbeat(details);
×
123
  }
×
124

125
  @Nonnull
126
  @Override
127
  public ActivityCompletionClient withContext(@Nonnull ActivitySerializationContext context) {
128
    return new ActivityCompletionClientImpl(factory, completionHandle, metricsScope, context);
×
129
  }
130

131
  private static WorkflowExecution toExecution(String workflowId, Optional<String> runId) {
132
    return WorkflowExecution.newBuilder()
×
133
        .setWorkflowId(workflowId)
×
134
        .setRunId(runId.orElse(""))
×
135
        .build();
×
136
  }
137
}
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