HADOOP-15316. GenericTestUtils can exceed maxSleepTime. Contributed by Adam Antal.

This commit is contained in:
Sean Mackrory 2018-07-12 16:45:07 +02:00
parent b37074be5a
commit 4f3f9391b0

View File

@ -661,7 +661,7 @@ public SleepAnswer(int minSleepTime, int maxSleepTime) {
public Object answer(InvocationOnMock invocation) throws Throwable {
boolean interrupted = false;
try {
Thread.sleep(r.nextInt(maxSleepTime) + minSleepTime);
Thread.sleep(r.nextInt(maxSleepTime - minSleepTime) + minSleepTime);
} catch (InterruptedException ie) {
interrupted = true;
}