ableegoldman commented on code in PR #18152:
URL: https://github.com/apache/kafka/pull/18152#discussion_r1883105957


##########
streams/src/main/java/org/apache/kafka/streams/internals/AutoOffsetResetInternal.java:
##########
@@ -31,6 +31,13 @@ public StrategyType offsetResetStrategy() {
         return offsetResetStrategy;
     }
 
+    // calling `Optional.get()` w/o checking `isPresent()` results in a 
warning that we suppress
+    // (there is unfortunately no speficif suppression for `Optional.get()` 
warnings)
+    //
+    // we do call `get()` unconditionally on purpose here, as it should only 
be called before `offsetResetStrategy()`
+    // was used to verify that the strategy is "by_duration"
+    // if the strategy is not "by_duration" and `duration()` is called,
+    // we want to fail right away to surface the bug in the caller code

Review Comment:
   eg 
   ```
   if (isEmpty) {
     final String errorMsg = String.format("Duration was unexpectedly empty. 
This should only ever be called after checking that the offsetResetStrategy() 
was 'by_duration'. Actual strategy was %s", offsetResetStrategy());
     log.error(errorMsg);
     throw new IllegalStateException(errorMsg);
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to