Fixed possible race condition in short-lived synchrynous commands

This commit is contained in:
GideonLeGrange 2013-07-12 10:28:55 +02:00
parent b11bd4fd1e
commit 900ce2f91c
1 changed files with 4 additions and 2 deletions

View File

@ -429,8 +429,10 @@ public class ApiConnection {
private List<Result> getResults() throws ApiCommandException, ApiConnectionException {
try {
synchronized (this) {
wait();
synchronized (this) { // don't wait if we already have a result.
if ((err == null) && results.isEmpty()) {
wait();
}
}
} catch (InterruptedException ex) {
throw new ApiConnectionException(ex.getMessage(), ex);