Skip to content

Commit

Permalink
Fix #8067 Use nanotime for DosFilter rate tracker
Browse files Browse the repository at this point in the history
updates from review
  • Loading branch information
gregw committed Jun 2, 2022
1 parent 437b45c commit 6234b3f
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -1216,7 +1216,7 @@ public RateTracker(ServletContext context, String filterName, String id, RateTyp
}

/**
* @param now the time now (in milliseconds)
* @param now the time now (in nanoseconds)
* @return the current calculated request rate over the last second
*/
public OverLimit isRateExceeded(long now)
Expand All @@ -1237,7 +1237,7 @@ public OverLimit isRateExceeded(long now)
long rate = (now - last);
if (TimeUnit.NANOSECONDS.toSeconds(rate) < 1L)
{
return new Overage(Duration.ofMillis(rate), _maxRequestsPerSecond);
return new Overage(Duration.ofNanos(rate), _maxRequestsPerSecond);
}
return null;
}
Expand Down

0 comments on commit 6234b3f

Please sign in to comment.