@Override
  public void subscribe(final Subscriber<? super Row> subscriber) {
    if (polling) {
      throw new IllegalStateException("Cannot set subscriber if polling");
    }
    synchronized (this) {
      subscribing = true;
      super.subscribe(subscriber);
    }
  }
@Test
  public void shouldNotSubscribeIfFailed() throws Exception {
    // Given
    handleQueryResultError();

    CountDownLatch latch = new CountDownLatch(1);
    context.runOnContext(v -> {
      // When / Then
      final Exception e = assertThrows(IllegalStateException.class, () -> queryResult.subscribe(subscriber));
      assertThat(e.getMessage(), containsString("Cannot subscribe to failed publisher"));
      latch.countDown();
    });
    awaitLatch(latch);
  }