mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2334202269


##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -51,7 +52,10 @@ public void add(final MeteredIterator iterator) {
 
         if (openIterators.size() == 1) {
             metricName = 
StateStoreMetrics.addOldestOpenIteratorGauge(taskId.toString(), metricsScope, 
name, streamsMetrics,
-                (config, now) -> openIterators.first().startTimestamp()
+                (config, now) -> {
+                    final Iterator<MeteredIterator> openIteratorsIterator = 
openIterators.iterator();
+                    return openIteratorsIterator.hasNext() ? 
openIteratorsIterator.next().startTimestamp() : null;

Review Comment:
   I think we we ever want to return `null` -- that why we added dynamic 
register/deregister behavior.
   
   I believe, we would need to somehow cache the "last result" before we remove 
the last iterator.



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