BehaviorProcessor extends FlowableProcessor<T> { @Override public void onSubscribe(Subscription s) { if (terminalEvent.get() != null) { s.cancel(); return; } s.request(Long.MAX_VALUE); } @SuppressWarnings("unchecked")  BehaviorProcessor();   BehaviorProcessor(T defaultValue); @CheckReturnValue @NonNull static BehaviorProcessor<T> create(); @CheckReturnValue @NonNull static BehaviorProcessor<T> createDefault(T defaultValue); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); @Experimental boolean offer(T t); @Override boolean hasSubscribers(); @Override @Nullable Throwable getThrowable(); @Nullable T getValue(); Object[] getValues(); @SuppressWarnings("unchecked") T[] getValues(T[] array); @Override boolean hasComplete(); @Override boolean hasThrowable(); boolean hasValue();  }
@Test public void onSubscribe() { BehaviorProcessor<Object> p = BehaviorProcessor.create(); BooleanSubscription bs = new BooleanSubscription(); p.onSubscribe(bs); assertFalse(bs.isCancelled()); p.onComplete(); bs = new BooleanSubscription(); p.onSubscribe(bs); assertTrue(bs.isCancelled()); }