DomGarguilo commented on code in PR #6041:
URL: https://github.com/apache/accumulo/pull/6041#discussion_r2673231106
##########
test/src/main/java/org/apache/accumulo/test/util/Wait.java:
##########
@@ -103,14 +106,14 @@ public static void waitFor(final Condition condition,
final long duration, final
final String failMessage) {
final int timeoutFactor = getTimeoutFactor(e -> 1); // default to factor
of 1
- final long scaledDurationNanos = MILLISECONDS.toNanos(duration) *
timeoutFactor;
+ final Duration scaledDuration =
Duration.ofMillis(duration).multipliedBy(timeoutFactor);
Review Comment:
so currently in the `Wait.waitFor()` code we have:
```java
final int timeoutFactor = getTimeoutFactor(e -> 1); // default to factor
of 1
final Duration scaledWaitDuration =
Duration.ofMillis(duration).multipliedBy(timeoutFactor);
final long scaledSleepMillis = sleepMillis * timeoutFactor;
final CountDownTimer maxWaitTimer =
CountDownTimer.startNew(scaledWaitDuration);
boolean success;
try {
success = condition.isSatisfied();
while (!success && !maxWaitTimer.isExpired()) {
MILLISECONDS.sleep(scaledSleepMillis);
success = condition.isSatisfied();
}
}
```
We still have the potential overflow scenario when calculating
`scaledSleepMillis`. We could do `Math.multiplyExact()` which will throw then
we could either let the exception throw or catch and set it to Long.MAX_VALUE.
Or just leave it as is and ignore the potential 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]