{"action":"created","comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments/29570260","id":29570260,"diff_hunk":"@@ -191,41 +188,45 @@ void pollQueue() {\n                  */\n                 counter = 1;\n \n-//                middle:\n                 while (!scheduledUnsubscribe.isUnsubscribed()) {\n-                    if (failure) {\n-                        child.onError(error);\n-                        return;\n-                    } else {\n-                        if (requested == 0 && completed && queue.isEmpty()) {\n+                    //make a local copy of the volatile finished\n+                    //so that it is only read once in this loop \n+                    boolean _finished = finished;\n+                    if (_finished) {\n+                        if (error != null) {\n+                            //even if there are onNext in the queue we eagerly notify of error\n+                            child.onError(error);","path":"src/main/java/rx/internal/operators/OperatorObserveOn.java","position":84,"original_position":84,"commit_id":"429fe04da43a80cc88b36016d616d9919be96223","original_commit_id":"429fe04da43a80cc88b36016d616d9919be96223","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},"body":"I meant ```error```.","created_at":"2015-05-04T07:51:11Z","updated_at":"2015-05-04T07:51:11Z","html_url":"https://github.com/ReactiveX/RxJava/pull/2929#discussion_r29570260","pull_request_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929","_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments/29570260"},"html":{"href":"https://github.com/ReactiveX/RxJava/pull/2929#discussion_r29570260"},"pull_request":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929"}}},"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929","id":34513519,"html_url":"https://github.com/ReactiveX/RxJava/pull/2929","diff_url":"https://github.com/ReactiveX/RxJava/pull/2929.diff","patch_url":"https://github.com/ReactiveX/RxJava/pull/2929.patch","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2929","number":2929,"state":"open","locked":false,"title":"OperatorObserveOn onComplete can be emitted despite onError being called","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},"body":"This is a fix for a race condition in `OperatorObserveOn` where if thread A gets to L164 and thread B starts the pollQueue loop then it will act as if the stream had completed normally instead of with an error. \r\n\r\nThe effect is that a stream could appear to complete normally when in fact an error had occurred.\r\n\r\nUsing two boolean volatiles `completed` and `failed` that as a pair were not atomically updated/read exposed us to this race condition. \r\n\r\nThe fix is to use a single volatile integer `status` to represent the  states ACTIVE, COMPLETED, ERRORED to replace `completed` and `failed`.\r\n\r\n\r\n","created_at":"2015-05-01T00:26:33Z","updated_at":"2015-05-04T07:51:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8af3ed89d4537ce31545e3ca1a87915a88cba834","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929/commits","review_comments_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929/comments","review_comment_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2929/comments","statuses_url":"https://api.github.com/repos/ReactiveX/RxJava/statuses/429fe04da43a80cc88b36016d616d9919be96223","head":{"label":"davidmoten:observe-on-race","ref":"observe-on-race","sha":"429fe04da43a80cc88b36016d616d9919be96223","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},"repo":{"id":23173070,"name":"RxJava","full_name":"davidmoten/RxJava","owner":{"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},"private":false,"html_url":"https://github.com/davidmoten/RxJava","description":"RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.","fork":true,"url":"https://api.github.com/repos/davidmoten/RxJava","forks_url":"https://api.github.com/repos/davidmoten/RxJava/forks","keys_url":"https://api.github.com/repos/davidmoten/RxJava/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidmoten/RxJava/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidmoten/RxJava/teams","hooks_url":"https://api.github.com/repos/davidmoten/RxJava/hooks","issue_events_url":"https://api.github.com/repos/davidmoten/RxJava/issues/events{/number}","events_url":"https://api.github.com/repos/davidmoten/RxJava/events","assignees_url":"https://api.github.com/repos/davidmoten/RxJava/assignees{/user}","branches_url":"https://api.github.com/repos/davidmoten/RxJava/branches{/branch}","tags_url":"https://api.github.com/repos/davidmoten/RxJava/tags","blobs_url":"https://api.github.com/repos/davidmoten/RxJava/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidmoten/RxJava/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidmoten/RxJava/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidmoten/RxJava/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidmoten/RxJava/statuses/{sha}","languages_url":"https://api.github.com/repos/davidmoten/RxJava/languages","stargazers_url":"https://api.github.com/repos/davidmoten/RxJava/stargazers","contributors_url":"https://api.github.com/repos/davidmoten/RxJava/contributors","subscribers_url":"https://api.github.com/repos/davidmoten/RxJava/subscribers","subscription_url":"https://api.github.com/repos/davidmoten/RxJava/subscription","commits_url":"https://api.github.com/repos/davidmoten/RxJava/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidmoten/RxJava/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidmoten/RxJava/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidmoten/RxJava/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidmoten/RxJava/contents/{+path}","compare_url":"https://api.github.com/repos/davidmoten/RxJava/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidmoten/RxJava/merges","archive_url":"https://api.github.com/repos/davidmoten/RxJava/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidmoten/RxJava/downloads","issues_url":"https://api.github.com/repos/davidmoten/RxJava/issues{/number}","pulls_url":"https://api.github.com/repos/davidmoten/RxJava/pulls{/number}","milestones_url":"https://api.github.com/repos/davidmoten/RxJava/milestones{/number}","notifications_url":"https://api.github.com/repos/davidmoten/RxJava/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidmoten/RxJava/labels{/name}","releases_url":"https://api.github.com/repos/davidmoten/RxJava/releases{/id}","created_at":"2014-08-21T03:37:09Z","updated_at":"2015-04-20T08:12:30Z","pushed_at":"2015-05-04T06:51:24Z","git_url":"git://github.com/davidmoten/RxJava.git","ssh_url":"git@github.com:davidmoten/RxJava.git","clone_url":"https://github.com/davidmoten/RxJava.git","svn_url":"https://github.com/davidmoten/RxJava","homepage":"","size":17605,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"1.x"}},"base":{"label":"ReactiveX:1.x","ref":"1.x","sha":"253248455c8ebe12e35809c2dcfd2f298a780a74","user":{"login":"ReactiveX","id":6407041,"avatar_url":"https://avatars.githubusercontent.com/u/6407041?v=3","gravatar_id":"","url":"https://api.github.com/users/ReactiveX","html_url":"https://github.com/ReactiveX","followers_url":"https://api.github.com/users/ReactiveX/followers","following_url":"https://api.github.com/users/ReactiveX/following{/other_user}","gists_url":"https://api.github.com/users/ReactiveX/gists{/gist_id}","starred_url":"https://api.github.com/users/ReactiveX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReactiveX/subscriptions","organizations_url":"https://api.github.com/users/ReactiveX/orgs","repos_url":"https://api.github.com/users/ReactiveX/repos","events_url":"https://api.github.com/users/ReactiveX/events{/privacy}","received_events_url":"https://api.github.com/users/ReactiveX/received_events","type":"Organization","site_admin":false},"repo":{"id":7508411,"name":"RxJava","full_name":"ReactiveX/RxJava","owner":{"login":"ReactiveX","id":6407041,"avatar_url":"https://avatars.githubusercontent.com/u/6407041?v=3","gravatar_id":"","url":"https://api.github.com/users/ReactiveX","html_url":"https://github.com/ReactiveX","followers_url":"https://api.github.com/users/ReactiveX/followers","following_url":"https://api.github.com/users/ReactiveX/following{/other_user}","gists_url":"https://api.github.com/users/ReactiveX/gists{/gist_id}","starred_url":"https://api.github.com/users/ReactiveX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReactiveX/subscriptions","organizations_url":"https://api.github.com/users/ReactiveX/orgs","repos_url":"https://api.github.com/users/ReactiveX/repos","events_url":"https://api.github.com/users/ReactiveX/events{/privacy}","received_events_url":"https://api.github.com/users/ReactiveX/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ReactiveX/RxJava","description":"RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.","fork":false,"url":"https://api.github.com/repos/ReactiveX/RxJava","forks_url":"https://api.github.com/repos/ReactiveX/RxJava/forks","keys_url":"https://api.github.com/repos/ReactiveX/RxJava/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ReactiveX/RxJava/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ReactiveX/RxJava/teams","hooks_url":"https://api.github.com/repos/ReactiveX/RxJava/hooks","issue_events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/events{/number}","events_url":"https://api.github.com/repos/ReactiveX/RxJava/events","assignees_url":"https://api.github.com/repos/ReactiveX/RxJava/assignees{/user}","branches_url":"https://api.github.com/repos/ReactiveX/RxJava/branches{/branch}","tags_url":"https://api.github.com/repos/ReactiveX/RxJava/tags","blobs_url":"https://api.github.com/repos/ReactiveX/RxJava/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ReactiveX/RxJava/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ReactiveX/RxJava/git/refs{/sha}","trees_url":"https://api.github.com/repos/ReactiveX/RxJava/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ReactiveX/RxJava/statuses/{sha}","languages_url":"https://api.github.com/repos/ReactiveX/RxJava/languages","stargazers_url":"https://api.github.com/repos/ReactiveX/RxJava/stargazers","contributors_url":"https://api.github.com/repos/ReactiveX/RxJava/contributors","subscribers_url":"https://api.github.com/repos/ReactiveX/RxJava/subscribers","subscription_url":"https://api.github.com/repos/ReactiveX/RxJava/subscription","commits_url":"https://api.github.com/repos/ReactiveX/RxJava/commits{/sha}","git_commits_url":"https://api.github.com/repos/ReactiveX/RxJava/git/commits{/sha}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/comments{/number}","issue_comment_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments{/number}","contents_url":"https://api.github.com/repos/ReactiveX/RxJava/contents/{+path}","compare_url":"https://api.github.com/repos/ReactiveX/RxJava/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ReactiveX/RxJava/merges","archive_url":"https://api.github.com/repos/ReactiveX/RxJava/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ReactiveX/RxJava/downloads","issues_url":"https://api.github.com/repos/ReactiveX/RxJava/issues{/number}","pulls_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls{/number}","milestones_url":"https://api.github.com/repos/ReactiveX/RxJava/milestones{/number}","notifications_url":"https://api.github.com/repos/ReactiveX/RxJava/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/labels{/name}","releases_url":"https://api.github.com/repos/ReactiveX/RxJava/releases{/id}","created_at":"2013-01-08T20:11:48Z","updated_at":"2015-05-04T03:57:56Z","pushed_at":"2015-05-04T06:51:26Z","git_url":"git://github.com/ReactiveX/RxJava.git","ssh_url":"git@github.com:ReactiveX/RxJava.git","clone_url":"https://github.com/ReactiveX/RxJava.git","svn_url":"https://github.com/ReactiveX/RxJava","homepage":"","size":393194,"stargazers_count":5432,"watchers_count":5432,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":770,"mirror_url":null,"open_issues_count":137,"forks":770,"open_issues":137,"watchers":5432,"default_branch":"1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929"},"html":{"href":"https://github.com/ReactiveX/RxJava/pull/2929"},"issue":{"href":"https://api.github.com/repos/ReactiveX/RxJava/issues/2929"},"comments":{"href":"https://api.github.com/repos/ReactiveX/RxJava/issues/2929/comments"},"review_comments":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929/comments"},"review_comment":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2929/commits"},"statuses":{"href":"https://api.github.com/repos/ReactiveX/RxJava/statuses/429fe04da43a80cc88b36016d616d9919be96223"}}}}