{"action":"created","comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments/73793603","id":73793603,"diff_hunk":"@@ -28,29 +30,47 @@ public ObservableFromPublisher(Publisher<? extends T> publisher) {\n \n     @Override\n     protected void subscribeActual(final Observer<? super T> o) {\n-        publisher.subscribe(new Subscriber<T>() {\n-\n-            @Override\n-            public void onComplete() {\n-                o.onComplete();\n-            }\n-\n-            @Override\n-            public void onError(Throwable t) {\n-                o.onError(t);\n-            }\n-\n-            @Override\n-            public void onNext(T t) {\n-                o.onNext(t);\n-            }\n-\n-            @Override\n-            public void onSubscribe(Subscription inner) {\n-                o.onSubscribe(Disposables.from(inner));\n-                inner.request(Long.MAX_VALUE);\n-            }\n-\n-        });\n+        publisher.subscribe(new PublisherSubscriber<T>(o));\n+    }\n+\n+    static final class PublisherSubscriber<T>\n+    extends AtomicReference<Subscription>\n+    implements Subscriber<T>, Disposable {\n+\n+        private final Observer<? super T> o;\n+\n+        PublisherSubscriber(Observer<? super T> o) {\n+            this.o = o;\n+        }\n+\n+        @Override\n+        public void onComplete() {\n+            o.onComplete();\n+        }\n+\n+        @Override\n+        public void onError(Throwable t) {\n+            o.onError(t);\n+        }\n+\n+        @Override\n+        public void onNext(T t) {\n+            o.onNext(t);\n+        }\n+\n+        @Override\n+        public void onSubscribe(Subscription inner) {\n+            SubscriptionHelper.setOnce(this, inner);\n+            o.onSubscribe(this);\n+            inner.request(Long.MAX_VALUE);\n+        }\n+\n+        @Override public void dispose() {\n+            SubscriptionHelper.dispose(this);","path":"src/main/java/io/reactivex/internal/operators/observable/ObservableFromPublisher.java","position":69,"original_position":75,"commit_id":"2470e9604aeb444cfd33a0200564fe63f6b560ba","original_commit_id":"2470e9604aeb444cfd33a0200564fe63f6b560ba","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":"switch to `AtomicBoolean` and:\r\n\r\n```java\r\nif (compareAndSet(false, true)) {\r\n    inner.cancel();\r\n}\r\n```","created_at":"2016-08-06T23:44:18Z","updated_at":"2016-08-06T23:44:18Z","html_url":"https://github.com/ReactiveX/RxJava/pull/4291#discussion_r73793603","pull_request_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291","_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments/73793603"},"html":{"href":"https://github.com/ReactiveX/RxJava/pull/4291#discussion_r73793603"},"pull_request":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291"}}},"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291","id":80353265,"html_url":"https://github.com/ReactiveX/RxJava/pull/4291","diff_url":"https://github.com/ReactiveX/RxJava/pull/4291.diff","patch_url":"https://github.com/ReactiveX/RxJava/pull/4291.patch","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4291","number":4291,"state":"open","locked":false,"title":"2.x: Promote anonymous Observables to top-level types.","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-06T23:05:44Z","updated_at":"2016-08-06T23:44:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bba84e06aacf83851413e5bf599c448551a0cb3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291/commits","review_comments_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291/comments","review_comment_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4291/comments","statuses_url":"https://api.github.com/repos/ReactiveX/RxJava/statuses/2470e9604aeb444cfd33a0200564fe63f6b560ba","head":{"label":"JakeWharton:jw/top-level-types","ref":"jw/top-level-types","sha":"2470e9604aeb444cfd33a0200564fe63f6b560ba","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"repo":{"id":40632236,"name":"RxJava","full_name":"JakeWharton/RxJava","owner":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JakeWharton/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/JakeWharton/RxJava","forks_url":"https://api.github.com/repos/JakeWharton/RxJava/forks","keys_url":"https://api.github.com/repos/JakeWharton/RxJava/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JakeWharton/RxJava/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JakeWharton/RxJava/teams","hooks_url":"https://api.github.com/repos/JakeWharton/RxJava/hooks","issue_events_url":"https://api.github.com/repos/JakeWharton/RxJava/issues/events{/number}","events_url":"https://api.github.com/repos/JakeWharton/RxJava/events","assignees_url":"https://api.github.com/repos/JakeWharton/RxJava/assignees{/user}","branches_url":"https://api.github.com/repos/JakeWharton/RxJava/branches{/branch}","tags_url":"https://api.github.com/repos/JakeWharton/RxJava/tags","blobs_url":"https://api.github.com/repos/JakeWharton/RxJava/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JakeWharton/RxJava/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JakeWharton/RxJava/git/refs{/sha}","trees_url":"https://api.github.com/repos/JakeWharton/RxJava/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JakeWharton/RxJava/statuses/{sha}","languages_url":"https://api.github.com/repos/JakeWharton/RxJava/languages","stargazers_url":"https://api.github.com/repos/JakeWharton/RxJava/stargazers","contributors_url":"https://api.github.com/repos/JakeWharton/RxJava/contributors","subscribers_url":"https://api.github.com/repos/JakeWharton/RxJava/subscribers","subscription_url":"https://api.github.com/repos/JakeWharton/RxJava/subscription","commits_url":"https://api.github.com/repos/JakeWharton/RxJava/commits{/sha}","git_commits_url":"https://api.github.com/repos/JakeWharton/RxJava/git/commits{/sha}","comments_url":"https://api.github.com/repos/JakeWharton/RxJava/comments{/number}","issue_comment_url":"https://api.github.com/repos/JakeWharton/RxJava/issues/comments{/number}","contents_url":"https://api.github.com/repos/JakeWharton/RxJava/contents/{+path}","compare_url":"https://api.github.com/repos/JakeWharton/RxJava/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JakeWharton/RxJava/merges","archive_url":"https://api.github.com/repos/JakeWharton/RxJava/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JakeWharton/RxJava/downloads","issues_url":"https://api.github.com/repos/JakeWharton/RxJava/issues{/number}","pulls_url":"https://api.github.com/repos/JakeWharton/RxJava/pulls{/number}","milestones_url":"https://api.github.com/repos/JakeWharton/RxJava/milestones{/number}","notifications_url":"https://api.github.com/repos/JakeWharton/RxJava/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JakeWharton/RxJava/labels{/name}","releases_url":"https://api.github.com/repos/JakeWharton/RxJava/releases{/id}","deployments_url":"https://api.github.com/repos/JakeWharton/RxJava/deployments","created_at":"2015-08-13T01:15:37Z","updated_at":"2016-07-05T02:50:03Z","pushed_at":"2016-08-06T23:24:36Z","git_url":"git://github.com/JakeWharton/RxJava.git","ssh_url":"git@github.com:JakeWharton/RxJava.git","clone_url":"https://github.com/JakeWharton/RxJava.git","svn_url":"https://github.com/JakeWharton/RxJava","homepage":"","size":26082,"stargazers_count":16,"watchers_count":16,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":0,"forks":6,"open_issues":0,"watchers":16,"default_branch":"1.x"}},"base":{"label":"ReactiveX:2.x","ref":"2.x","sha":"6b0f1b05353cf0c3ef63a1b9923b77721f35227f","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}","deployments_url":"https://api.github.com/repos/ReactiveX/RxJava/deployments","created_at":"2013-01-08T20:11:48Z","updated_at":"2016-08-06T21:00:16Z","pushed_at":"2016-08-06T23:24:37Z","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":36947,"stargazers_count":15805,"watchers_count":15805,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2719,"mirror_url":null,"open_issues_count":77,"forks":2719,"open_issues":77,"watchers":15805,"default_branch":"1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291"},"html":{"href":"https://github.com/ReactiveX/RxJava/pull/4291"},"issue":{"href":"https://api.github.com/repos/ReactiveX/RxJava/issues/4291"},"comments":{"href":"https://api.github.com/repos/ReactiveX/RxJava/issues/4291/comments"},"review_comments":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291/comments"},"review_comment":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/4291/commits"},"statuses":{"href":"https://api.github.com/repos/ReactiveX/RxJava/statuses/2470e9604aeb444cfd33a0200564fe63f6b560ba"}}}}
{"actor":{"display_login":"akarnokd"}}