From cca34fd872dd08ae306ae7a6d00355d2b5167ed1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 6 Apr 2015 21:18:59 +0200 Subject: [PATCH] First check condition, then remaining wait in SynchronizationPoint as otherwhise SynchronizationPoint may report NoResponseException when there was in fact a success or failure reported in case there are multiple threads waiting for the condition. --- .../main/java/org/jivesoftware/smack/SynchronizationPoint.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java b/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java index 78918a06a..c52242350 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/SynchronizationPoint.java @@ -221,12 +221,11 @@ public class SynchronizationPoint { long remainingWait = TimeUnit.MILLISECONDS.toNanos(connection.getPacketReplyTimeout()); while (state == State.RequestSent || state == State.Initial) { try { - remainingWait = condition.awaitNanos( - remainingWait); if (remainingWait <= 0) { state = State.NoResponse; break; } + remainingWait = condition.awaitNanos(remainingWait); } catch (InterruptedException e) { LOGGER.log(Level.WARNING, "Thread interrupt while waiting for condition or timeout ignored", e); }