GREEN: Implementierung von `BackOffState` korrigiert
authorKai Moritz <kai@juplo.de>
Fri, 10 Jan 2025 23:25:55 +0000 (00:25 +0100)
committerKai Moritz <kai@juplo.de>
Thu, 6 Feb 2025 17:04:39 +0000 (18:04 +0100)
src/main/java/de/juplo/kafka/BackOffState.java

index c6b3e8c..0015ebe 100644 (file)
@@ -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
     {