{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2799","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2799/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2799/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2799/events","html_url":"https://github.com/ReactiveX/RxJava/issues/2799","id":59824175,"number":2799,"title":".onBackpressureBlock() - please clarify this weird behaviour","user":{"login":"wendigo","id":66972,"avatar_url":"https://avatars.githubusercontent.com/u/66972?v=3","gravatar_id":"","url":"https://api.github.com/users/wendigo","html_url":"https://github.com/wendigo","followers_url":"https://api.github.com/users/wendigo/followers","following_url":"https://api.github.com/users/wendigo/following{/other_user}","gists_url":"https://api.github.com/users/wendigo/gists{/gist_id}","starred_url":"https://api.github.com/users/wendigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wendigo/subscriptions","organizations_url":"https://api.github.com/users/wendigo/orgs","repos_url":"https://api.github.com/users/wendigo/repos","events_url":"https://api.github.com/users/wendigo/events{/privacy}","received_events_url":"https://api.github.com/users/wendigo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveX/RxJava/labels/Bug","name":"Bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-03-04T16:40:15Z","updated_at":"2015-03-06T07:07:58Z","closed_at":null,"body":"Given this piece of code:\r\n\r\n```\r\n        Observable.create(subscriber -> {\r\n            long counter = 0;\r\n\r\n            while (counter++ < Long.MAX_VALUE) {\r\n                System.out.println(\"onNext(\" + counter + \")\");\r\n\r\n                if (!subscriber.isUnsubscribed()) {\r\n                    subscriber.onNext(counter);\r\n                } else {\r\n                    break;\r\n                }\r\n\r\n                System.out.println(\"Subscribe.onNext(\" + value + \")\");\r\n            }\r\n        })\r\n        .onBackpressureBlock(2)\r\n        .subscribeOn(Schedulers.newThread())\r\n        .observeOn(Schedulers.computation())\r\n        .subscribe(System.out::println);\r\n```\r\n\r\nOn version 1.0.7 above code will hang on producing element on position RxRingBuffer.SIZE + 2 (maxQueueLength):\r\n\r\n```\r\n...\r\nafterOnNext(127)\r\nonNext(128)\r\nafterOnNext(128)\r\nSubscribe.onNext(128)\r\nonNext(129)\r\nafterOnNext(129)\r\nonNext(130)\r\nafterOnNext(130)\r\nonNext(131)\r\n```\r\n\r\nIf we switch order of subscribe/observeOn (observeOn before subscribeOn) - it will work as expected :)\r\n\r\nAlso it will throw *MissingBackpressureException* without onBackpressure* (as expected).\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/77516386","html_url":"https://github.com/ReactiveX/RxJava/issues/2799#issuecomment-77516386","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2799","id":77516386,"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-03-06T07:07:58Z","updated_at":"2015-03-06T07:07:58Z","body":"Blocking and backpressure-continuations don't play well together: the same issue happened in #2466 with a different kind of blocking implementation. The solution is to move the subscribeOn before the blocking part (which can't be done if the very first source is the blocking one). We can put an emphasis on this fact in the javadoc of ```onBackpressureBuffer``` but if one isn't in control of the downstream, such downstream can introduce subscribeOn and the trouble is back. I'd say lets drop the operator for now."}}