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


##########
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:
   actually now I'm thinking we should maybe just have a check instead of 
suppressing the warnings -- I know this _should_ never happen, but if due to 
some bug (eg introduced in a future refactoring) it actually is 
Optional.empty(), then it will be better to check and throw a helpful error 
message here. it's not a heavy API call so we may as well?



-- 
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