Patch for awaitNanos() for coarse-grained clocks
If System.nanoTime() returns the same value twice in awaitNanos()
then (remaining == initialNanos) will be true but the code
will conclude that a (less likely) overflow occurred.
Bug: 24284239
(cherry-picked from commit 8fc2ac0fa8eb47ce607f8412e469d4f680b6ef85)
Change-Id: I3b9d573ea822e18f4c1849c8ab66071e66274a50
diff --git a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
index 47a02a9..a74fb24 100644
--- a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
+++ b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
@@ -1838,7 +1838,10 @@
if (interruptMode != 0)
reportInterruptAfterWait(interruptMode);
long remaining = deadline - System.nanoTime(); // avoid overflow
- return (remaining < initialNanos) ? remaining : Long.MIN_VALUE;
+ // BEGIN android-note Changed from < to <= http://b/24284239
+ // return (remaining < initialNanos) ? remaining : Long.MIN_VALUE;
+ return (remaining <= initialNanos) ? remaining : Long.MIN_VALUE;
+ // END android-note
}
/**
diff --git a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
index bfe88e5..8823b6f 100644
--- a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
+++ b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
@@ -2062,7 +2062,10 @@
if (interruptMode != 0)
reportInterruptAfterWait(interruptMode);
long remaining = deadline - System.nanoTime(); // avoid overflow
- return (remaining < initialNanos) ? remaining : Long.MIN_VALUE;
+ // BEGIN android-note Changed from < to <= http://b/24284239
+ // return (remaining < initialNanos) ? remaining : Long.MIN_VALUE;
+ return (remaining <= initialNanos) ? remaining : Long.MIN_VALUE;
+ // END android-note
}
/**