From: Kai Moritz Date: Fri, 10 Jan 2025 23:25:55 +0000 (+0100) Subject: GREEN: Implementierung von `BackOffState` korrigiert X-Git-Tag: consumer/spring-consumer--error-handling--COMMITS--2025-02~8 X-Git-Url: https://juplo.de/gitweb/?a=commitdiff_plain;h=445743ae9d5beddfd61076a8d660a537b4093c0c;p=demos%2Fkafka%2Ftraining GREEN: Implementierung von `BackOffState` korrigiert --- 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 {