Apache9 commented on PR #5099:
URL: https://github.com/apache/hbase/pull/5099#issuecomment-1479245014
The implementation of RateLimiter is a bit strange to me. The name of the
'canExecute' method indicates that it just tests whether a request can execute,
which should be read only, but in the method we will update avail? Then what is
the purpose for consume method?
And in consume method
```
public synchronized void consume(final long amount) {
if (isBypass()) {
return;
}
if (amount >= 0) {
this.avail -= amount;
if (this.avail < 0) {
this.avail = 0;
}
} else {
if (this.avail <= Long.MAX_VALUE + amount) { // <===== here
this.avail -= amount;
this.avail = Math.min(this.avail, this.limit);
} else {
this.avail = this.limit;
}
}
}
```
Why we do a 'Long.MAX_VALUE + amount'? It will always overflow?
--
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]