ARTEMIS-1401 Numerical overflow fix when using System::nanoTime
This commit is contained in:
parent
65a0c6104a
commit
35c3475092
|
@ -330,7 +330,7 @@ public class NettyConnection implements Connection {
|
||||||
parkNanos = 1000L;
|
parkNanos = 1000L;
|
||||||
}
|
}
|
||||||
boolean canWrite;
|
boolean canWrite;
|
||||||
while (!(canWrite = canWrite(requiredCapacity)) && System.nanoTime() < deadline) {
|
while (!(canWrite = canWrite(requiredCapacity)) && (System.nanoTime() - deadline) < 0) {
|
||||||
//periodically check the connection state
|
//periodically check the connection state
|
||||||
checkConnectionState();
|
checkConnectionState();
|
||||||
LockSupport.parkNanos(parkNanos);
|
LockSupport.parkNanos(parkNanos);
|
||||||
|
|
|
@ -386,7 +386,7 @@ public final class TimedBuffer {
|
||||||
lastFlushTime = System.nanoTime();
|
lastFlushTime = System.nanoTime();
|
||||||
flush();
|
flush();
|
||||||
|
|
||||||
} else if (bufferObserver != null && System.nanoTime() > lastFlushTime + timeout) {
|
} else if (bufferObserver != null && System.nanoTime() - lastFlushTime > timeout) {
|
||||||
lastFlushTime = System.nanoTime();
|
lastFlushTime = System.nanoTime();
|
||||||
// if not using flush we will spin and do the time checks manually
|
// if not using flush we will spin and do the time checks manually
|
||||||
flush();
|
flush();
|
||||||
|
|
|
@ -227,7 +227,7 @@ public class TimedBufferTest extends ActiveMQTestBase {
|
||||||
private static void spinSleep(long timeout) {
|
private static void spinSleep(long timeout) {
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
final long deadline = System.nanoTime() + timeout;
|
final long deadline = System.nanoTime() + timeout;
|
||||||
while (System.nanoTime() < deadline) {
|
while (System.nanoTime() - deadline < 0) {
|
||||||
//spin wait
|
//spin wait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue