Skip to content

Commit

Permalink
tests: fix another flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Apr 24, 2020
1 parent d050cf2 commit ae62c7f
Showing 1 changed file with 3 additions and 9 deletions.
Expand Up @@ -27,6 +27,7 @@
import com.google.cloud.spanner.admin.database.v1.MockDatabaseAdminImpl;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Uninterruptibles;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.Any;
import com.google.protobuf.Empty;
Expand All @@ -45,6 +46,7 @@
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
Expand All @@ -63,7 +65,6 @@
public class DatabaseAdminGaxTest {
public static class DelayedStatusRuntimeException extends RuntimeException {
private final long millis;
private boolean hasWaited = false;

public DelayedStatusRuntimeException(StatusRuntimeException cause, long millis) {
super(cause);
Expand All @@ -72,14 +73,7 @@ public DelayedStatusRuntimeException(StatusRuntimeException cause, long millis)

@Override
public synchronized Throwable getCause() {
if (!hasWaited) {
try {
Thread.sleep(millis);
hasWaited = true;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
Uninterruptibles.sleepUninterruptibly(millis, TimeUnit.MILLISECONDS);
return super.getCause();
}
}
Expand Down

0 comments on commit ae62c7f

Please sign in to comment.