Skip to content

Commit 6876e44

Browse files
author
Vlad Alexandru Ionescu
committed
merging bug22965 into default
2 parents 315cd7b + 658a113 commit 6876e44

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/com/rabbitmq/utility/BlockingCell.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,17 @@ public synchronized T get() throws InterruptedException {
7676
* @throws InterruptedException if this thread is interrupted
7777
*/
7878
public synchronized T get(long timeout) throws InterruptedException, TimeoutException {
79-
if (timeout < 0 && timeout != INFINITY)
79+
if (timeout == INFINITY) return get();
80+
81+
if (timeout < 0)
8082
throw new AssertionError("Timeout cannot be less than zero");
81-
82-
if (!_filled && timeout != 0) {
83-
wait(timeout == INFINITY ? 0 : timeout);
83+
84+
long maxTime = System.currentTimeMillis() + timeout;
85+
long now;
86+
while (!_filled && (now = System.currentTimeMillis()) < maxTime) {
87+
wait(maxTime - now);
8488
}
85-
89+
8690
if (!_filled)
8791
throw new TimeoutException();
8892

0 commit comments

Comments
 (0)