Skip to content

Commit 8ee9299

Browse files
committed
refactor: create an instance just for testing isLastAttempt
1 parent 9f50fd0 commit 8ee9299

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,8 @@ private PostExecutionControl<R> handleErrorStatusHandler(R resource, R originalR
170170
Exception e) throws Exception {
171171
if (isErrorStatusHandlerPresent()) {
172172
try {
173-
RetryInfo retryInfo = context.getRetryInfo().orElse(new RetryInfo() {
174-
@Override
175-
public int getAttemptCount() {
176-
return 0;
177-
}
178-
179-
@Override
180-
public boolean isLastAttempt() {
181-
// on first try, we can only rely on the configured behavior
182-
// if enabled, will at least produce one RetryExecution
183-
return !controller.getConfiguration().getRetry().enabled();
184-
}
185-
});
173+
RetryInfo retryInfo =
174+
context.getRetryInfo().orElse(controller.getConfiguration().getRetry().initExecution());
186175
((DefaultContext<R>) context).setRetryInfo(retryInfo);
187176
var errorStatusUpdateControl = ((ErrorStatusHandler<R>) controller.getReconciler())
188177
.updateErrorStatus(resource, context, e);

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/GenericRetry.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ public GenericRetry withLinearRetry() {
9292
return this;
9393
}
9494

95-
@Override
96-
public boolean enabled() {
97-
return this.maxAttempts > 0;
98-
}
99-
10095
@Override
10196
public void initFrom(GradualRetry configuration) {
10297
this.initialInterval = configuration.initialInterval();

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/retry/Retry.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,4 @@ public interface Retry {
55

66
RetryExecution initExecution();
77

8-
default boolean enabled() {
9-
return false;
10-
}
11-
128
}

0 commit comments

Comments
 (0)