Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions smack-core/src/main/java/org/jivesoftware/smack/SmackFuture.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,21 @@ public final synchronized V getOrThrow() throws E, InterruptedException {
public final synchronized V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
final long deadline = System.currentTimeMillis() + unit.toMillis(timeout);
while (result != null && exception != null) {
while (result == null && exception == null) {
final long waitTimeRemaining = deadline - System.currentTimeMillis();
if (waitTimeRemaining > 0) {
futureWait(waitTimeRemaining);
if (waitTimeRemaining <= 0
// this may be the case when the system time was changed meanwhile!
&& unit.toMillis(timeout) < waitTimeRemaining) {
break;
}
futureWait(waitTimeRemaining);
}

if (cancelled) {
throw new CancellationException();
}

if (result == null || exception == null) {
if (result == null && exception == null) {
throw new TimeoutException();
}

Expand Down
Loading