nicktelford commented on code in PR #17713:
URL: https://github.com/apache/kafka/pull/17713#discussion_r1833719869


##########
streams/src/main/java/org/apache/kafka/streams/state/internals/MeteredKeyValueStore.java:
##########
@@ -154,7 +155,13 @@ private void registerMetrics() {
         StateStoreMetrics.addNumOpenIteratorsGauge(taskId.toString(), 
metricsScope, name(), streamsMetrics,
                 (config, now) -> numOpenIterators.sum());
         StateStoreMetrics.addOldestOpenIteratorGauge(taskId.toString(), 
metricsScope, name(), streamsMetrics,
-                (config, now) -> openIterators.isEmpty() ? null : 
openIterators.first().startTimestamp()
+                (config, now) -> {
+                    try {
+                        return openIterators.isEmpty() ? null : 
openIterators.first().startTimestamp();

Review Comment:
   Actually, another option is to use `ConcurrentSkipListMap<MeteredIterator, 
Object>`. This is actually what `ConcurrentSkipListSet` uses internally, and 
`ConcurrentSkipListMap` provides `firstEntry()`, which returns `null` when 
empty.
   
   The downside of this is that everwhere that adds to `openIterators` would 
need to use a dummy value (`ConcurrentSkipListSet` uses `Boolaen.TRUE`), which 
might look a bit odd.



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