Skip to content

Commit

Permalink
make sure we set our state as soon as we know it - this should fix th…
Browse files Browse the repository at this point in the history
…ose concurrency issues the unit tests keep seeing
  • Loading branch information
jmazzitelli committed Feb 3, 2015
1 parent 234201c commit 292b879
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public T get() throws InterruptedException, ExecutionException {
// From there on out we never take from the blocking Q.
if (responseMessage == null) {
responseMessage = responseQ.take();
state = State.DONE; // since we have a response, set state to DONE to ensure our caller knows our state
}
return responseMessage;
}
Expand All @@ -134,6 +135,7 @@ public T get(long timeout, TimeUnit unit) throws InterruptedException, Execution
throw new TimeoutException();
}
responseMessage = item;
state = State.DONE; // since we have a response, set state to DONE to ensure our caller knows our state
}

return responseMessage;
Expand All @@ -148,8 +150,8 @@ public void addListener(Runnable listener, Executor exec) {
protected void onBasicMessage(T basicMessage) {
// if we already got a message or were cancelled, ignore any additional messages we might receive
if (!isDone()) {
state = State.DONE;
if (responseQ.offer(basicMessage)) {
state = State.DONE;
executionList.execute();
} else {
msglog.errorCannotStoreIncomingMessageFutureInvalid();
Expand Down

0 comments on commit 292b879

Please sign in to comment.