1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

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.
This commit is contained in:
Florian Schmaus 2015-04-06 21:18:59 +02:00
parent 83aa6838d9
commit cca34fd872

View file

@ -221,12 +221,11 @@ public class SynchronizationPoint<E extends Exception> {
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);
}