frankvicky commented on code in PR #21736:
URL: https://github.com/apache/kafka/pull/21736#discussion_r2936657806


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredTimestampedKeyValueStoreWithHeaders.java:
##########
@@ -343,12 +396,23 @@ public long startTimestamp() {
 
         @Override
         public boolean hasNext() {
-            return iter.hasNext();
+            return cachedNext != null || iter.hasNext();
         }
 
         @Override
         public KeyValue<K, V> next() {
+            if (cachedNext != null) {
+                final KeyValue<K, V> result = cachedNext;
+                cachedNext = null;
+                return result;
+            }
+
             final KeyValue<Bytes, byte[]> keyValue = iter.next();
+
+            if (keyValue == null) {

Review Comment:
   Great catch.
   I didn't notice this iterator contract before.



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