Skip to content

Commit c206efe

Browse files
authored
deflake SubscriberImplTest (#1495)
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.
1 parent 994479f commit c206efe

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/FakeSubscriberServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ public void modifyAckDeadline(
264264
public void sendError(Throwable error) throws InterruptedException {
265265
waitForRegistedSubscription();
266266
synchronized (openedStreams) {
267+
waitForOpenedStreams(1);
267268
Stream stream = openedStreams.get(getAndAdvanceCurrentStream());
268269
stream.responseObserver.onError(error);
269270
closeStream(stream);

0 commit comments

Comments
 (0)