Skip to content

Commit

Permalink
Fix count matching to prevert number overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Jan 29, 2025
1 parent d300321 commit d838709
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
var count = callCache.getIfPresent(key);
if (count == null) {
callCache.put(key, 1);
} else {
} else if (count < RPCConstants.LOGIN_RATE_LIMIT) {
callCache.put(key, count + 1);
}

if (count != null && count > RPCConstants.LOGIN_RATE_LIMIT) {
if (count != null && count >= RPCConstants.LOGIN_RATE_LIMIT) {
status = Status.RESOURCE_EXHAUSTED.withDescription("Too many login attempts");
} else {
return Contexts.interceptCall(
Expand Down

0 comments on commit d838709

Please sign in to comment.