ARTEMIS-1312 TimedBuffer doubled timeout with blocking flush

This commit is contained in:
Francesco Nigro 2017-08-01 14:52:07 +02:00 committed by Clebert Suconic
parent 14d840de58
commit 74f243cc4d
2 changed files with 3 additions and 3 deletions

View File

@ -395,7 +395,7 @@ public final class TimedBuffer {
}
//it could wait until the timeout is expired
final long timeFromTheLastFlush = System.nanoTime() - lastFlushTime;
final long timeToSleep = timeFromTheLastFlush - timeout;
final long timeToSleep = timeout - timeFromTheLastFlush;
if (timeToSleep > 0) {
sleepIfPossible(timeToSleep);
}

View File

@ -385,7 +385,7 @@ public class TimedBufferTest extends ActiveMQTestBase {
@Test
public void timeoutShouldMatchFlushIOPSWithNotBlockingFlush() {
//use a large timeout in order to be reactive
final long timeout = TimeUnit.SECONDS.toNanos(2);
final long timeout = TimeUnit.MILLISECONDS.toNanos(100);
assert ((int) timeout) > 0;
//it is optimistic: the timeout and the blockingDeviceFlushTime are a perfect match
final long deviceTime = timeout;
@ -426,7 +426,7 @@ public class TimedBufferTest extends ActiveMQTestBase {
@Test
public void timeoutShouldMatchFlushIOPSWithBlockingFlush() {
//use a large timeout in order to be reactive
final long timeout = TimeUnit.SECONDS.toNanos(2);
final long timeout = TimeUnit.MILLISECONDS.toNanos(100);
assert ((int) timeout) > 0;
//it is optimistic: the timeout and the blockingDeviceFlushTime are a perfect match
final long deviceTime = timeout;