Skip to content

Commit

Permalink
Remove unnecessary explicit NaN check.
Browse files Browse the repository at this point in the history
Fixes #7255
Fixes #7260

RELNOTES=n/a
PiperOrigin-RevId: 645396592
  • Loading branch information
moinb authored and Google Java Core Libraries committed Jun 21, 2024
1 parent 1648ef7 commit 20348c7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void testSimpleRateUpdate() {

assertThrows(IllegalArgumentException.class, () -> limiter.setRate(0.0));
assertThrows(IllegalArgumentException.class, () -> limiter.setRate(-10.0));
assertThrows(IllegalArgumentException.class, () -> limiter.setRate(Double.NaN));
}

public void testAcquireParameterValidation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ private Object mutex() {
* @throws IllegalArgumentException if {@code permitsPerSecond} is negative or zero
*/
public final void setRate(double permitsPerSecond) {
checkArgument(
permitsPerSecond > 0.0 && !Double.isNaN(permitsPerSecond), "rate must be positive");
checkArgument(permitsPerSecond > 0.0, "rate must be positive");
synchronized (mutex()) {
doSetRate(permitsPerSecond, stopwatch.readMicros());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void testSimpleRateUpdate() {

assertThrows(IllegalArgumentException.class, () -> limiter.setRate(0.0));
assertThrows(IllegalArgumentException.class, () -> limiter.setRate(-10.0));
assertThrows(IllegalArgumentException.class, () -> limiter.setRate(Double.NaN));
}

public void testAcquireParameterValidation() {
Expand Down
3 changes: 1 addition & 2 deletions guava/src/com/google/common/util/concurrent/RateLimiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ private Object mutex() {
* @throws IllegalArgumentException if {@code permitsPerSecond} is negative or zero
*/
public final void setRate(double permitsPerSecond) {
checkArgument(
permitsPerSecond > 0.0 && !Double.isNaN(permitsPerSecond), "rate must be positive");
checkArgument(permitsPerSecond > 0.0, "rate must be positive");
synchronized (mutex()) {
doSetRate(permitsPerSecond, stopwatch.readMicros());
}
Expand Down

0 comments on commit 20348c7

Please sign in to comment.