Hangleton commented on code in PR #12045:
URL: https://github.com/apache/kafka/pull/12045#discussion_r862786317


##########
clients/src/main/java/org/apache/kafka/common/metrics/stats/SampledStat.java:
##########
@@ -87,8 +103,9 @@ public Sample oldest(long now) {
         Sample oldest = this.samples.get(0);
         for (int i = 1; i < this.samples.size(); i++) {
             Sample curr = this.samples.get(i);
-            if (curr.lastWindowMs < oldest.lastWindowMs)
+            if ((curr.getLastWindowMs() < oldest.getLastWindowMs()) && 
curr.isActive()) { // only consider active samples

Review Comment:
   Is the `isActive` really required? Before the oldest sample is computed, 
expired samples are reset which brings the `lastWindonMs` equal to `now`. 
   
   Marginal note: this assumes at least one sample is active (that is if all 
samples between 1 and `samples.size()` are not active, the first sample in the 
list has to be active and would be the current sample).



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to