{"action":"created","comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments/63255013","id":63255013,"diff_hunk":"@@ -0,0 +1,34 @@\n+/**\n+ * Copyright 2016 Netflix, Inc.\n+ * \n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ * \n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ * \n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package rx.internal.schedulers;\n+\n+/**\n+ * Used only for providing context around where work was scheduled should an error occur in a different thread.\n+ */\n+public class SchedulerContextException extends Exception {\n+    public static Throwable create() {\n+        if (System.getProperty(\"rxjava.captureSchedulerContext\", \"false\").equals(\"true\")) {","path":"src/main/java/rx/internal/schedulers/SchedulerContextException.java","position":null,"original_position":23,"commit_id":"e27781421f20037f45aaa66da70b093a2b5e1fa7","original_commit_id":"9630081dc8ef75edad8dc397a661cf61d4ee57fd","user":{"login":"abersnaze","id":406038,"avatar_url":"https://avatars.githubusercontent.com/u/406038?v=3","gravatar_id":"","url":"https://api.github.com/users/abersnaze","html_url":"https://github.com/abersnaze","followers_url":"https://api.github.com/users/abersnaze/followers","following_url":"https://api.github.com/users/abersnaze/following{/other_user}","gists_url":"https://api.github.com/users/abersnaze/gists{/gist_id}","starred_url":"https://api.github.com/users/abersnaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abersnaze/subscriptions","organizations_url":"https://api.github.com/users/abersnaze/orgs","repos_url":"https://api.github.com/users/abersnaze/repos","events_url":"https://api.github.com/users/abersnaze/events{/privacy}","received_events_url":"https://api.github.com/users/abersnaze/received_events","type":"User","site_admin":false},"body":"anything else @JakeWharton @akarnokd?","created_at":"2016-05-13T21:40:05Z","updated_at":"2016-05-13T21:40:05Z","html_url":"https://github.com/ReactiveX/RxJava/pull/3937#discussion_r63255013","pull_request_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937","_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments/63255013"},"html":{"href":"https://github.com/ReactiveX/RxJava/pull/3937#discussion_r63255013"},"pull_request":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937"}}},"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937","id":70033433,"html_url":"https://github.com/ReactiveX/RxJava/pull/3937","diff_url":"https://github.com/ReactiveX/RxJava/pull/3937.diff","patch_url":"https://github.com/ReactiveX/RxJava/pull/3937.patch","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3937","number":3937,"state":"open","locked":false,"title":"Change the workers to capture the stack trace","user":{"login":"abersnaze","id":406038,"avatar_url":"https://avatars.githubusercontent.com/u/406038?v=3","gravatar_id":"","url":"https://api.github.com/users/abersnaze","html_url":"https://github.com/abersnaze","followers_url":"https://api.github.com/users/abersnaze/followers","following_url":"https://api.github.com/users/abersnaze/following{/other_user}","gists_url":"https://api.github.com/users/abersnaze/gists{/gist_id}","starred_url":"https://api.github.com/users/abersnaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abersnaze/subscriptions","organizations_url":"https://api.github.com/users/abersnaze/orgs","repos_url":"https://api.github.com/users/abersnaze/repos","events_url":"https://api.github.com/users/abersnaze/events{/privacy}","received_events_url":"https://api.github.com/users/abersnaze/received_events","type":"User","site_admin":false},"body":"Watched @dlew presentation of the pit falls of debugging RxJava https://www.youtube.com/watch?v=QdmkXL7XikQ&feature=youtu.be&t=38m12s\r\n\r\nThis change is to create an exception when a thread based `Scheduler.Worker` is constructed and reused it for all subsequent scheduled actions to increase the readability of uncaught and fatal exceptions that bubble up to the schedulers but spread the cost out across many scheduled actions.\r\n\r\nA future improvement to spread the cost out even more, that I didn't want to do in the first attempt, would to create the exception when `Scheduler.io()` is called and reuse the exception across multiple `Worker`s.\r\n\r\nThe example from the presentation\r\n```\r\nimport rx.Observable;\r\nimport rx.schedulers.Schedulers;\r\n\r\npublic class Main {\r\n    public static void main(String[] args) throws InterruptedException {\r\n        Observable.empty()\r\n                .first()\r\n                .subscribeOn(Schedulers.io())\r\n                .subscribe();\r\n\r\n        Thread.sleep(100);\r\n    }\r\n}\r\n```\r\n\r\nUsed to print this just this exception with no mention the Main class.\r\n```\r\nException in thread \"RxIoScheduler-2\" java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. Add `onError` handling.\r\n\tat rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:65)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\tat java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)\r\n\tat java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: rx.exceptions.OnErrorNotImplementedException: Sequence contains no elements\r\n\tat rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:374)\r\n\tat rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:1)\r\n\tat rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44)\r\n\tat rx.observers.SafeSubscriber._onError(SafeSubscriber.java:157)\r\n\tat rx.observers.SafeSubscriber.onError(SafeSubscriber.java:120)\r\n\tat rx.internal.operators.OperatorSubscribeOn$1$1.onError(OperatorSubscribeOn.java:59)\r\n\tat rx.internal.operators.OperatorSingle$ParentSubscriber.onCompleted(OperatorSingle.java:116)\r\n\tat rx.internal.operators.OperatorTake$1.onCompleted(OperatorTake.java:56)\r\n\tat rx.internal.operators.EmptyObservableHolder.call(EmptyObservableHolder.java:44)\r\n\tat rx.internal.operators.EmptyObservableHolder.call(EmptyObservableHolder.java:1)\r\n\tat rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)\r\n\tat rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:1)\r\n\tat rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)\r\n\tat rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:1)\r\n\tat rx.Observable.unsafeSubscribe(Observable.java:8460)\r\n\tat rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)\r\n\tat rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:222)\r\n\tat rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:60)\r\n\t... 7 more\r\nCaused by: java.util.NoSuchElementException: Sequence contains no elements\r\n\t... 19 more\r\n```\r\n\r\nBut will now print the exception above but with an additional caused by\r\n```\r\nCaused by: rx.internal.schedulers.SchedulerContextException: Asynchronous work scheduled at\r\n\tat rx.internal.schedulers.NewThreadWorker.<init>(NewThreadWorker.java:36)\r\n\tat rx.internal.schedulers.CachedThreadScheduler$ThreadWorker.<init>(CachedThreadScheduler.java:235)\r\n\tat rx.internal.schedulers.CachedThreadScheduler$CachedWorkerPool.get(CachedThreadScheduler.java:86)\r\n\tat rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker.<init>(CachedThreadScheduler.java:187)\r\n\tat rx.internal.schedulers.CachedThreadScheduler.createWorker(CachedThreadScheduler.java:173)\r\n\tat rx.internal.operators.OperatorSubscribeOn.call(OperatorSubscribeOn.java:42)\r\n\tat rx.internal.operators.OperatorSubscribeOn.call(OperatorSubscribeOn.java:1)\r\n\tat rx.Observable.subscribe(Observable.java:8553)\r\n\tat rx.Observable.subscribe(Observable.java:8520)\r\n\tat rx.Observable.subscribe(Observable.java:8316)\r\n\tat rx.schedulers.Main.main(Main.java:10)\r\n```","created_at":"2016-05-13T17:49:01Z","updated_at":"2016-05-13T21:40:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"318128bbb756378336d8f687c397176d220a8d77","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937/commits","review_comments_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937/comments","review_comment_url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3937/comments","statuses_url":"https://api.github.com/repos/ReactiveX/RxJava/statuses/e27781421f20037f45aaa66da70b093a2b5e1fa7","head":{"label":"abersnaze:stacks","ref":"stacks","sha":"e27781421f20037f45aaa66da70b093a2b5e1fa7","user":{"login":"abersnaze","id":406038,"avatar_url":"https://avatars.githubusercontent.com/u/406038?v=3","gravatar_id":"","url":"https://api.github.com/users/abersnaze","html_url":"https://github.com/abersnaze","followers_url":"https://api.github.com/users/abersnaze/followers","following_url":"https://api.github.com/users/abersnaze/following{/other_user}","gists_url":"https://api.github.com/users/abersnaze/gists{/gist_id}","starred_url":"https://api.github.com/users/abersnaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abersnaze/subscriptions","organizations_url":"https://api.github.com/users/abersnaze/orgs","repos_url":"https://api.github.com/users/abersnaze/repos","events_url":"https://api.github.com/users/abersnaze/events{/privacy}","received_events_url":"https://api.github.com/users/abersnaze/received_events","type":"User","site_admin":false},"repo":{"id":7616124,"name":"RxJava","full_name":"abersnaze/RxJava","owner":{"login":"abersnaze","id":406038,"avatar_url":"https://avatars.githubusercontent.com/u/406038?v=3","gravatar_id":"","url":"https://api.github.com/users/abersnaze","html_url":"https://github.com/abersnaze","followers_url":"https://api.github.com/users/abersnaze/followers","following_url":"https://api.github.com/users/abersnaze/following{/other_user}","gists_url":"https://api.github.com/users/abersnaze/gists{/gist_id}","starred_url":"https://api.github.com/users/abersnaze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abersnaze/subscriptions","organizations_url":"https://api.github.com/users/abersnaze/orgs","repos_url":"https://api.github.com/users/abersnaze/repos","events_url":"https://api.github.com/users/abersnaze/events{/privacy}","received_events_url":"https://api.github.com/users/abersnaze/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abersnaze/RxJava","description":"","fork":true,"url":"https://api.github.com/repos/abersnaze/RxJava","forks_url":"https://api.github.com/repos/abersnaze/RxJava/forks","keys_url":"https://api.github.com/repos/abersnaze/RxJava/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abersnaze/RxJava/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abersnaze/RxJava/teams","hooks_url":"https://api.github.com/repos/abersnaze/RxJava/hooks","issue_events_url":"https://api.github.com/repos/abersnaze/RxJava/issues/events{/number}","events_url":"https://api.github.com/repos/abersnaze/RxJava/events","assignees_url":"https://api.github.com/repos/abersnaze/RxJava/assignees{/user}","branches_url":"https://api.github.com/repos/abersnaze/RxJava/branches{/branch}","tags_url":"https://api.github.com/repos/abersnaze/RxJava/tags","blobs_url":"https://api.github.com/repos/abersnaze/RxJava/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abersnaze/RxJava/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abersnaze/RxJava/git/refs{/sha}","trees_url":"https://api.github.com/repos/abersnaze/RxJava/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abersnaze/RxJava/statuses/{sha}","languages_url":"https://api.github.com/repos/abersnaze/RxJava/languages","stargazers_url":"https://api.github.com/repos/abersnaze/RxJava/stargazers","contributors_url":"https://api.github.com/repos/abersnaze/RxJava/contributors","subscribers_url":"https://api.github.com/repos/abersnaze/RxJava/subscribers","subscription_url":"https://api.github.com/repos/abersnaze/RxJava/subscription","commits_url":"https://api.github.com/repos/abersnaze/RxJava/commits{/sha}","git_commits_url":"https://api.github.com/repos/abersnaze/RxJava/git/commits{/sha}","comments_url":"https://api.github.com/repos/abersnaze/RxJava/comments{/number}","issue_comment_url":"https://api.github.com/repos/abersnaze/RxJava/issues/comments{/number}","contents_url":"https://api.github.com/repos/abersnaze/RxJava/contents/{+path}","compare_url":"https://api.github.com/repos/abersnaze/RxJava/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abersnaze/RxJava/merges","archive_url":"https://api.github.com/repos/abersnaze/RxJava/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abersnaze/RxJava/downloads","issues_url":"https://api.github.com/repos/abersnaze/RxJava/issues{/number}","pulls_url":"https://api.github.com/repos/abersnaze/RxJava/pulls{/number}","milestones_url":"https://api.github.com/repos/abersnaze/RxJava/milestones{/number}","notifications_url":"https://api.github.com/repos/abersnaze/RxJava/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abersnaze/RxJava/labels{/name}","releases_url":"https://api.github.com/repos/abersnaze/RxJava/releases{/id}","deployments_url":"https://api.github.com/repos/abersnaze/RxJava/deployments","created_at":"2013-01-15T01:05:07Z","updated_at":"2015-11-04T17:45:06Z","pushed_at":"2016-05-13T21:39:22Z","git_url":"git://github.com/abersnaze/RxJava.git","ssh_url":"git@github.com:abersnaze/RxJava.git","clone_url":"https://github.com/abersnaze/RxJava.git","svn_url":"https://github.com/abersnaze/RxJava","homepage":null,"size":19119,"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":"0.20.x"}},"base":{"label":"ReactiveX:1.x","ref":"1.x","sha":"d43c05cb0f011e7647cdf176fcd2620bb4a95e8e","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-05-13T20:02:45Z","pushed_at":"2016-05-13T21:39: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":33928,"stargazers_count":13729,"watchers_count":13729,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2243,"mirror_url":null,"open_issues_count":120,"forks":2243,"open_issues":120,"watchers":13729,"default_branch":"1.x"}},"_links":{"self":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937"},"html":{"href":"https://github.com/ReactiveX/RxJava/pull/3937"},"issue":{"href":"https://api.github.com/repos/ReactiveX/RxJava/issues/3937"},"comments":{"href":"https://api.github.com/repos/ReactiveX/RxJava/issues/3937/comments"},"review_comments":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937/comments"},"review_comment":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ReactiveX/RxJava/pulls/3937/commits"},"statuses":{"href":"https://api.github.com/repos/ReactiveX/RxJava/statuses/e27781421f20037f45aaa66da70b093a2b5e1fa7"}}}}