{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4870","repository_url":"https://api.github.com/repos/ReactiveX/RxJava","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4870/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4870/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4870/events","html_url":"https://github.com/ReactiveX/RxJava/issues/4870","id":190909676,"number":4870,"title":"1.2.2 operator share() not work correctly with backpressure","user":{"login":"yueban","id":5647837,"avatar_url":"https://avatars.githubusercontent.com/u/5647837?v=3","gravatar_id":"","url":"https://api.github.com/users/yueban","html_url":"https://github.com/yueban","followers_url":"https://api.github.com/users/yueban/followers","following_url":"https://api.github.com/users/yueban/following{/other_user}","gists_url":"https://api.github.com/users/yueban/gists{/gist_id}","starred_url":"https://api.github.com/users/yueban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yueban/subscriptions","organizations_url":"https://api.github.com/users/yueban/orgs","repos_url":"https://api.github.com/users/yueban/repos","events_url":"https://api.github.com/users/yueban/events{/privacy}","received_events_url":"https://api.github.com/users/yueban/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":6,"created_at":"2016-11-22T05:18:24Z","updated_at":"2016-11-22T09:21:48Z","closed_at":null,"body":"I'm implementing a download module with RxJava. I use operator share() to make the source Observable can be subscribed by multiple Subscriber. Here my code below.\r\n\r\n**use share() singly:**:  It will emits several items first, and then stop emiting until onError (`MissingBackpressureException`) called.\r\n**use onBackpressureLatest() singly:** works fine, but lose multicast\r\n**use share() + onBackpressureLatest()**: It will emits several items first, and then stop emiting until onComplete called.\r\n\r\n```java\r\nObservable<DownloadTaskModel> observable =\r\n    mDownloadUploadRepository.download(downloadTaskModel.getUrl(), downloadTaskModel.getFil\r\n        downloadTaskModel.getFileSize(), downloadTaskModel.isOverwriteFile())\r\n        // share() to make multicast\r\n        // onBackpressureLatest() to avoid MissingBackpressureException\r\n        .share()\r\n        .onBackpressureLatest()\r\n        .doOnRequest(new Action1<Long>() {\r\n            @Override\r\n            public void call(Long aLong) {\r\n                synchronized (DownloadInteractorImpl.class) {\r\n                    downloadTaskModel.getTaskStatus().status = TaskStatus.Status.DEFAULT;\r\n                }\r\n            }\r\n        })\r\n        .doOnNext(new Action1<Progress>() {\r\n            @Override\r\n            public void call(Progress progress) {\r\n                synchronized (DownloadInteractorImpl.this) {\r\n                    TaskStatus taskStatus = downloadTaskModel.getTaskStatus();\r\n                    taskStatus.progress = progress.getProgress();\r\n                    taskStatus.length = progress.getTotalLength();\r\n                    taskStatus.status = progress.isComplete() ? TaskStatus.Status.COMPLETE\r\n                        : progress.isPause() ? TaskStatus.Status.PAUSE : TaskStatus.Status.\r\n                    if (downloadTaskModel.getTaskStatus().status == TaskStatus.Status.COMPL\r\n                        mDownloadTaskModelMap.remove(downloadTaskModel);\r\n                    }\r\n                }\r\n            }\r\n        })\r\n        .doOnError(new Action1<Throwable>() {\r\n            @Override\r\n            public void call(Throwable throwable) {\r\n                synchronized (DownloadInteractorImpl.this) {\r\n                    downloadTaskModel.getTaskStatus().status = TaskStatus.Status.FAIL;\r\n                    mDownloadTaskModelMap.remove(downloadTaskModel);\r\n                }\r\n            }\r\n        })\r\n        .map(new Func1<Progress, DownloadTaskModel>() {\r\n            @Override\r\n            public DownloadTaskModel call(Progress progress) {\r\n                return downloadTaskModel;\r\n            }\r\n        });\r\n```"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/262188280","html_url":"https://github.com/ReactiveX/RxJava/issues/4870#issuecomment-262188280","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4870","id":262188280,"user":{"login":"yueban","id":5647837,"avatar_url":"https://avatars.githubusercontent.com/u/5647837?v=3","gravatar_id":"","url":"https://api.github.com/users/yueban","html_url":"https://github.com/yueban","followers_url":"https://api.github.com/users/yueban/followers","following_url":"https://api.github.com/users/yueban/following{/other_user}","gists_url":"https://api.github.com/users/yueban/gists{/gist_id}","starred_url":"https://api.github.com/users/yueban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yueban/subscriptions","organizations_url":"https://api.github.com/users/yueban/orgs","repos_url":"https://api.github.com/users/yueban/repos","events_url":"https://api.github.com/users/yueban/events{/privacy}","received_events_url":"https://api.github.com/users/yueban/received_events","type":"User","site_admin":false},"created_at":"2016-11-22T09:21:48Z","updated_at":"2016-11-22T09:21:48Z","body":"Okay, I will extract a Demo on my github in a one day"}}
{"actor":{"display_login":"yueban"}}