{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2559","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2559/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2559/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2559/events","html_url":"https://github.com/ReactiveX/RxJava/pull/2559","id":55863512,"number":2559,"title":"OnSubscribeFromIterable - add request overflow check ","user":{"login":"davidmoten","id":318187,"avatar_url":"https://avatars.githubusercontent.com/u/318187?v=3","gravatar_id":"","url":"https://api.github.com/users/davidmoten","html_url":"https://github.com/davidmoten","followers_url":"https://api.github.com/users/davidmoten/followers","following_url":"https://api.github.com/users/davidmoten/following{/other_user}","gists_url":"https://api.github.com/users/davidmoten/gists{/gist_id}","starred_url":"https://api.github.com/users/davidmoten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidmoten/subscriptions","organizations_url":"https://api.github.com/users/davidmoten/orgs","repos_url":"https://api.github.com/users/davidmoten/repos","events_url":"https://api.github.com/users/davidmoten/events{/privacy}","received_events_url":"https://api.github.com/users/davidmoten/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-29T06:50:16Z","updated_at":"2015-01-29T09:01:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2559","html_url":"https://github.com/ReactiveX/RxJava/pull/2559","diff_url":"https://github.com/ReactiveX/RxJava/pull/2559.diff","patch_url":"https://github.com/ReactiveX/RxJava/pull/2559.patch"},"body":"A subscriber like so provokes a hang from ```OnSubscribeFromIterable``` due to overflow to negative of requested field:\r\n\r\n```java\r\n    @Override\r\n    public void onStart() {\r\n        request(2);\r\n    }\r\n    \r\n    @Override\r\n    public void onNext(Integer t) {\r\n        request(Long.MAX_VALUE-1);\r\n    }\r\n```\r\n\r\nI've moved the ```getAndAddRequest``` method that does the overflow check to a new ```rx.internal.operators.Util``` class that is also now used by the request overflow check in ```OperatorMerge```.\r\n\r\nOf course there are plenty more of these to be done. I propose to do them bit by bit.\r\n"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/71990859","html_url":"https://github.com/ReactiveX/RxJava/pull/2559#issuecomment-71990859","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2559","id":71990859,"user":{"login":"akarnokd","id":1269832,"avatar_url":"https://avatars.githubusercontent.com/u/1269832?v=3","gravatar_id":"","url":"https://api.github.com/users/akarnokd","html_url":"https://github.com/akarnokd","followers_url":"https://api.github.com/users/akarnokd/followers","following_url":"https://api.github.com/users/akarnokd/following{/other_user}","gists_url":"https://api.github.com/users/akarnokd/gists{/gist_id}","starred_url":"https://api.github.com/users/akarnokd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akarnokd/subscriptions","organizations_url":"https://api.github.com/users/akarnokd/orgs","repos_url":"https://api.github.com/users/akarnokd/repos","events_url":"https://api.github.com/users/akarnokd/events{/privacy}","received_events_url":"https://api.github.com/users/akarnokd/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T09:01:58Z","updated_at":"2015-01-29T09:01:58Z","body":"I think BackpressureUtils would be a better name and an AtomicLong overload would be great."}}