@Test public void requestNegative() { final List<Object> list = new ArrayList<Object>(); Subscriber<Object> sub = new Subscriber<Object>() { @Override public void onSubscribe(Subscription s) { s.request(-99); } @Override public void onNext(Object t) { list.add(t); } @Override public void onError(Throwable t) { list.add(t); } @Override public void onComplete() { list.add("Done"); } }; Flowable.range(1, 5).subscribe(sub); assertTrue(list.toString(), list.get(0) instanceof IllegalArgumentException); assertTrue(list.toString(), list.get(0).toString().contains("3.9")); }
@Override public void request(long n) { if (n <= 0) { cancel(); onError(new IllegalArgumentException("§3.9 violated: positive request amount required but it was " + n)); } else { SubscriptionHelper.deferredRequest(s, requested, n); } }
StrictSubscriber extends AtomicInteger implements FlowableSubscriber<T>, Subscription { @Override public void request(long n) { if (n <= 0) { cancel(); onError(new IllegalArgumentException("§3.9 violated: positive request amount required but it was " + n)); } else { SubscriptionHelper.deferredRequest(s, requested, n); } } }
StrictSubscriber extends AtomicInteger implements FlowableSubscriber<T>, Subscription { @Override public void request(long n) { if (n <= 0) { cancel(); onError(new IllegalArgumentException("§3.9 violated: positive request amount required but it was " + n)); } else { SubscriptionHelper.deferredRequest(s, requested, n); } } StrictSubscriber(Subscriber<? super T> actual); }
StrictSubscriber extends AtomicInteger implements FlowableSubscriber<T>, Subscription { @Override public void request(long n) { if (n <= 0) { cancel(); onError(new IllegalArgumentException("§3.9 violated: positive request amount required but it was " + n)); } else { SubscriptionHelper.deferredRequest(s, requested, n); } } StrictSubscriber(Subscriber<? super T> actual); @Override void request(long n); @Override void cancel(); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete(); }
StrictSubscriber extends AtomicInteger implements FlowableSubscriber<T>, Subscription { @Override public void request(long n) { if (n <= 0) { cancel(); onError(new IllegalArgumentException("§3.9 violated: positive request amount required but it was " + n)); } else { SubscriptionHelper.deferredRequest(s, requested, n); } } StrictSubscriber(Subscriber<? super T> actual); @Override void request(long n); @Override void cancel(); @Override void onSubscribe(Subscription s); @Override void onNext(T t); @Override void onError(Throwable t); @Override void onComplete();  }