Skip to content

Commit 82345d2

Browse files
committed
refactor: create an instance just for testing isLastAttempt
1 parent 7c6a1fe commit 82345d2

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
@@ -165,19 +165,8 @@ private PostExecutionControl<P> handleErrorStatusHandler(P resource, P originalR
165165
Exception e) throws Exception {
166166
if (isErrorStatusHandlerPresent()) {
167167
try {
168-
RetryInfo retryInfo = context.getRetryInfo().orElseGet(() -> new RetryInfo() {
169-
@Override
170-
public int getAttemptCount() {
171-
return 0;
172-
}
173-
174-
@Override
175-
public boolean isLastAttempt() {
176-
// on first try, we can only rely on the configured behavior
177-
// if enabled, will at least produce one RetryExecution
178-
return !controller.getConfiguration().getRetry().enabled();
179-
}
180-
});
168+
RetryInfo retryInfo =
169+
context.getRetryInfo().orElse(controller.getConfiguration().getRetry().initExecution());
181170
((DefaultContext<P>) context).setRetryInfo(retryInfo);
182171
var errorStatusUpdateControl = ((ErrorStatusHandler<P>) controller.getReconciler())
183172
.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)