From 445743ae9d5beddfd61076a8d660a537b4093c0c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 11 Jan 2025 00:25:55 +0100 Subject: [PATCH] GREEN: Implementierung von `BackOffState` korrigiert --- src/main/java/de/juplo/kafka/BackOffState.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/juplo/kafka/BackOffState.java b/src/main/java/de/juplo/kafka/BackOffState.java index c6b3e8c2..0015ebec 100644 --- a/src/main/java/de/juplo/kafka/BackOffState.java +++ b/src/main/java/de/juplo/kafka/BackOffState.java @@ -42,7 +42,6 @@ class BackOffState this.topicPartition = topicPartition; this.offset = offset; this.startTime = clock.instant(); - this.timeNextRetryIsDue = this.startTime; log.info( "{} - Back-Off requested for offset={} in {}", @@ -55,7 +54,7 @@ class BackOffState boolean isWaitingForNextRetry() { - if (backOffExecution == null) + if (timeNextRetryIsDue == null) { return false; } @@ -88,17 +87,17 @@ class BackOffState boolean isStarted(long offset) { - return this.offset == offset && timeNextRetryIsDue != null; + return this.offset == offset && backOffExecution != null; } boolean isCompleted() { - return backOffExecution == null && timeNextRetryIsDue != null; + return timeNextRetryIsDue == null; } void markAsCompleted() { - if (backOffExecution != null) + if (timeNextRetryIsDue != null) { log.info( "{} - {}. retry for offset={} in {} succeeded after {}", @@ -108,7 +107,6 @@ class BackOffState topicPartition, Duration.between(startTime, timeNextRetryIsDue)); - backOffExecution = null; timeNextRetryIsDue = null; } } @@ -119,7 +117,7 @@ class BackOffState if (backOffMillis == BackOffExecution.STOP) { - backOffExecution = null; + timeNextRetryIsDue = null; } else { -- 2.20.1