{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4880","repository_url":"https://api.github.com/repos/ReactiveX/RxJava","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4880/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4880/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4880/events","html_url":"https://github.com/ReactiveX/RxJava/issues/4880","id":191364173,"number":4880,"title":"2.x: CreateEmitter throws when onError called after dispose unlike 1.x","user":{"login":"Mauin","id":6169809,"avatar_url":"https://avatars.githubusercontent.com/u/6169809?v=3","gravatar_id":"","url":"https://api.github.com/users/Mauin","html_url":"https://github.com/Mauin","followers_url":"https://api.github.com/users/Mauin/followers","following_url":"https://api.github.com/users/Mauin/following{/other_user}","gists_url":"https://api.github.com/users/Mauin/gists{/gist_id}","starred_url":"https://api.github.com/users/Mauin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mauin/subscriptions","organizations_url":"https://api.github.com/users/Mauin/orgs","repos_url":"https://api.github.com/users/Mauin/repos","events_url":"https://api.github.com/users/Mauin/events{/privacy}","received_events_url":"https://api.github.com/users/Mauin/received_events","type":"User","site_admin":false},"labels":[{"id":24234455,"url":"https://api.github.com/repos/ReactiveX/RxJava/labels/Question","name":"Question","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-23T19:43:41Z","updated_at":"2016-11-23T19:59:53Z","closed_at":null,"body":"I have these two tests which behave differently in 1.x and 2.x.\r\n\r\n```java\r\n@org.junit.Test\r\npublic void testRxJava1() throws Exception {\r\n\tSubscription subscription = rx.Observable.fromEmitter(emitter -> {\r\n\t\temitter.onNext(1);\r\n\t\temitter.setCancellation(() -> emitter.onError(new IllegalArgumentException()));\r\n\t}, Emitter.BackpressureMode.NONE)\r\n\t\t\t.subscribe(\r\n\t\t\t\tinteger -> System.out.println(integer),\r\n\t\t\t\tthrowable -> throwable.printStackTrace()\r\n\t\t\t);\r\n\r\n\tsubscription.unsubscribe();\r\n}\r\n\r\n@org.junit.Test\r\npublic void testRxJava2() throws Exception {\r\n\tDisposable disposable = Observable.create(emitter -> {\r\n\t\temitter.onNext(1);\r\n\t\temitter.setCancellable(() -> emitter.onError(new IllegalArgumentException()));\r\n\t}).subscribe(\r\n\t\tinteger -> System.out.println(integer),\r\n\t\tthrowable -> throwable.printStackTrace()\r\n\t);\r\n\r\n\tdisposable.dispose();\r\n}\r\n```\r\n\r\nThe 2.x `CreateEmitter` ends up throwing the exception as an uncaught exception, the 1.x Emitter just returns if the Subscription has already been unsubscribed. \r\n\r\nThe Wiki at [Entering the Reactive World](https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#entering-the-reactive-world) makes it sounds like both should behave the same.\r\n\r\nWhat would be the correct usage in 2.x to get the same behaviour as in 1.x and not crashing the Application with the `emitter.onError(...)` call?"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/262616702","html_url":"https://github.com/ReactiveX/RxJava/issues/4880#issuecomment-262616702","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4880","id":262616702,"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":"2016-11-23T19:59:53Z","updated_at":"2016-11-23T19:59:53Z","body":"In 2.x, we signal all undeliverable exceptions, such as yours to the `RxJavaPlugins.onError` which by default forwards it to the thread's default uncaught error handler. You can install an error handler via `RxJavaPlugins.setOnError` and do something with such errors."}}
{"actor":{"display_login":"akarnokd"}}