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

uber / cadence-java-client / 2622

06 Nov 2024 10:24PM UTC coverage: 76.159% (-3.0%) from 79.182%
2622

Pull #948

buildkite

shijiesheng
fix format
Pull Request #948: fix bug in QueryWorkflowParameters.toString

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

617 existing lines in 8 files now uncovered.

14755 of 19374 relevant lines covered (76.16%)

0.76 hits per line

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

82.69
/src/main/java/com/uber/cadence/internal/common/RetryParameters.java
1
/*
2
 *  Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
 *
4
 *  Modifications copyright (C) 2017 Uber Technologies, Inc.
5
 *
6
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not
7
 *  use this file except in compliance with the License. A copy of the License is
8
 *  located at
9
 *
10
 *  http://aws.amazon.com/apache2.0
11
 *
12
 *  or in the "license" file accompanying this file. This file is distributed on
13
 *  an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
 *  express or implied. See the License for the specific language governing
15
 *  permissions and limitations under the License.
16
 */
17

18
package com.uber.cadence.internal.common;
19

20
import static com.uber.cadence.internal.common.OptionsUtils.roundUpToSeconds;
21

22
import com.uber.cadence.RetryPolicy;
23
import com.uber.cadence.common.RetryOptions;
24
import com.uber.m3.util.ImmutableList;
25
import java.util.ArrayList;
26
import java.util.List;
27

28
public final class RetryParameters {
29

30
  public int initialIntervalInSeconds;
31
  public double backoffCoefficient;
32
  public int maximumIntervalInSeconds;
33
  public int maximumAttempts;
34
  public List<String> nonRetriableErrorReasons;
35
  public int expirationIntervalInSeconds;
36

37
  public RetryParameters(RetryOptions retryOptions) {
1✔
38
    setBackoffCoefficient(retryOptions.getBackoffCoefficient());
1✔
39
    setExpirationIntervalInSeconds(
1✔
40
        (int) roundUpToSeconds(retryOptions.getExpiration()).getSeconds());
1✔
41
    setMaximumAttempts(retryOptions.getMaximumAttempts());
1✔
42
    setInitialIntervalInSeconds(
1✔
43
        (int) roundUpToSeconds(retryOptions.getInitialInterval()).getSeconds());
1✔
44
    setMaximumIntervalInSeconds(
1✔
45
        (int) roundUpToSeconds(retryOptions.getMaximumInterval()).getSeconds());
1✔
46
    // Use exception type name as the reason
47
    List<String> reasons = new ArrayList<>();
1✔
48
    // Use exception type name as the reason
49
    List<Class<? extends Throwable>> doNotRetry = retryOptions.getDoNotRetry();
1✔
50
    if (doNotRetry != null) {
1✔
51
      for (Class<? extends Throwable> r : doNotRetry) {
1✔
52
        reasons.add(r.getName());
1✔
53
      }
1✔
54
      setNonRetriableErrorReasons(reasons);
1✔
55
    }
56
  }
1✔
57

58
  public RetryParameters() {}
1✔
59

60
  public int getInitialIntervalInSeconds() {
61
    return initialIntervalInSeconds;
1✔
62
  }
63

64
  public void setInitialIntervalInSeconds(int initialIntervalInSeconds) {
65
    this.initialIntervalInSeconds = initialIntervalInSeconds;
1✔
66
  }
1✔
67

68
  public double getBackoffCoefficient() {
69
    return backoffCoefficient;
1✔
70
  }
71

72
  public void setBackoffCoefficient(double backoffCoefficient) {
73
    this.backoffCoefficient = backoffCoefficient;
1✔
74
  }
1✔
75

76
  public int getMaximumIntervalInSeconds() {
77
    return maximumIntervalInSeconds;
1✔
78
  }
79

80
  public void setMaximumIntervalInSeconds(int maximumIntervalInSeconds) {
81
    this.maximumIntervalInSeconds = maximumIntervalInSeconds;
1✔
82
  }
1✔
83

84
  public int getMaximumAttempts() {
85
    return maximumAttempts;
1✔
86
  }
87

88
  public void setMaximumAttempts(int maximumAttempts) {
89
    this.maximumAttempts = maximumAttempts;
1✔
90
  }
1✔
91

92
  public List<String> getNonRetriableErrorReasons() {
93
    return nonRetriableErrorReasons;
1✔
94
  }
95

96
  public void setNonRetriableErrorReasons(List<String> nonRetriableErrorReasons) {
97
    this.nonRetriableErrorReasons = nonRetriableErrorReasons;
1✔
98
  }
1✔
99

100
  public int getExpirationIntervalInSeconds() {
101
    return expirationIntervalInSeconds;
1✔
102
  }
103

104
  public void setExpirationIntervalInSeconds(int expirationIntervalInSeconds) {
105
    this.expirationIntervalInSeconds = expirationIntervalInSeconds;
1✔
106
  }
1✔
107

108
  public RetryParameters copy() {
109
    RetryParameters result = new RetryParameters();
×
110
    result.setMaximumIntervalInSeconds(maximumIntervalInSeconds);
×
111
    result.setNonRetriableErrorReasons(new ImmutableList<>(nonRetriableErrorReasons));
×
112
    result.setInitialIntervalInSeconds(initialIntervalInSeconds);
×
113
    result.setMaximumAttempts(maximumAttempts);
×
114
    result.setExpirationIntervalInSeconds(expirationIntervalInSeconds);
×
115
    result.setBackoffCoefficient(backoffCoefficient);
×
116
    return result;
×
117
  }
118

119
  public RetryPolicy toRetryPolicy() {
120
    return new RetryPolicy()
1✔
121
        .setNonRetriableErrorReasons(getNonRetriableErrorReasons())
1✔
122
        .setMaximumAttempts(getMaximumAttempts())
1✔
123
        .setInitialIntervalInSeconds(getInitialIntervalInSeconds())
1✔
124
        .setExpirationIntervalInSeconds(getExpirationIntervalInSeconds())
1✔
125
        .setBackoffCoefficient(getBackoffCoefficient())
1✔
126
        .setMaximumIntervalInSeconds(getMaximumIntervalInSeconds());
1✔
127
  }
128

129
  @Override
130
  public String toString() {
UNCOV
131
    return "RetryParameters{"
×
132
        + "initialIntervalInSeconds="
133
        + initialIntervalInSeconds
134
        + ", backoffCoefficient="
135
        + backoffCoefficient
136
        + ", maximumIntervalInSeconds="
137
        + maximumIntervalInSeconds
138
        + ", maximumAttempts="
139
        + maximumAttempts
140
        + ", nonRetriableErrorReasons="
141
        + nonRetriableErrorReasons
142
        + ", expirationIntervalInSeconds="
143
        + expirationIntervalInSeconds
144
        + '}';
145
  }
146
}
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