public boolean accept(final T t) {
    checkContext();
    if (isComplete() || hasSentComplete()) {
      throw new IllegalStateException("Cannot call accept after complete is called");
    }
    if (!isCancelled() && !isFailed()) {
      if (getDemand() == 0) {
        buffer.add(t);
      } else {
        doOnNext(t);
      }
    }
    return buffer.size() >= bufferMaxSize;
  }
@Test
  public void shouldNotAllowAcceptingAfterComplete() throws Exception {
    TestSubscriber<String> subscriber = new TestSubscriber<>(context);
    subscribeOnContext(subscriber);
    execOnContextAndWait(getBufferedPublisher()::complete);
    AtomicBoolean failed = new AtomicBoolean();
    execOnContextAndWait(() -> {
      try {
        getBufferedPublisher().accept("foo");
        failed.set(true);
      } catch (IllegalStateException e) {
        // OK
      }
    });
    assertThat(failed.get(), equalTo(false));
  }