@Test
public void publishFunctionCancelOuterAfterOneInnerBackpressured() {

    final AtomicReference<Flowable<Integer>> ref = new AtomicReference<Flowable<Integer>>();
    PublishProcessor<Integer> pp = PublishProcessor.create();
    final TestSubscriber<Integer> ts = pp.publish(new Function<Flowable<Integer>, Publisher<Integer>>() {
        @Override
        public Publisher<Integer> apply(Flowable<Integer> f) throws Exception {
            ref.set(f);
            return Flowable.never();
        }
    }).test();
    ref.get().subscribe(new TestSubscriber<Integer>(1L) {
        @Override
        public void onNext(Integer t) {
            super.onNext(t);
            onComplete();
            ts.cancel();
        }
    });
    pp.onNext(1);
}