Skip to content

Commit

Permalink
deflake SubscriberImplTest (#1495)
Browse files Browse the repository at this point in the history
This commit tries to deflake failures reported in https://ci.appveyor.com/project/garrettjonesgoogle/google-cloud-java/build/57 .

The failure seems to come from `FakeSubscriberServiceImpl::sendError`. When calling `getAndAdvanceCurrentStream`, we waited for there to be a subscription by waiting on the `subscriptionInitialized` variable.

The variable is notified before `addOpenedStream` is called though, and so it's possible that `getAndAdvanceCurrentStream` will see a list without any opened stream. The fix is to wait for at least one stream to be registered first.
  • Loading branch information
pongad authored Dec 22, 2016
1 parent 994479f commit c206efe
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public void modifyAckDeadline(
public void sendError(Throwable error) throws InterruptedException {
waitForRegistedSubscription();
synchronized (openedStreams) {
waitForOpenedStreams(1);
Stream stream = openedStreams.get(getAndAdvanceCurrentStream());
stream.responseObserver.onError(error);
closeStream(stream);
Expand Down

0 comments on commit c206efe

Please sign in to comment.