{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4840","repository_url":"https://api.github.com/repos/ReactiveX/RxJava","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4840/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4840/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4840/events","html_url":"https://github.com/ReactiveX/RxJava/issues/4840","id":188903392,"number":4840,"title":"Why  resubscribe the source observable emit same output when I use retryWhen operator?","user":{"login":"xturbofan","id":5610070,"avatar_url":"https://avatars.githubusercontent.com/u/5610070?v=3","gravatar_id":"","url":"https://api.github.com/users/xturbofan","html_url":"https://github.com/xturbofan","followers_url":"https://api.github.com/users/xturbofan/followers","following_url":"https://api.github.com/users/xturbofan/following{/other_user}","gists_url":"https://api.github.com/users/xturbofan/gists{/gist_id}","starred_url":"https://api.github.com/users/xturbofan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xturbofan/subscriptions","organizations_url":"https://api.github.com/users/xturbofan/orgs","repos_url":"https://api.github.com/users/xturbofan/repos","events_url":"https://api.github.com/users/xturbofan/events{/privacy}","received_events_url":"https://api.github.com/users/xturbofan/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":3,"created_at":"2016-11-12T09:58:00Z","updated_at":"2016-11-12T12:59:01Z","closed_at":null,"body":"code:\r\n```java\r\nstr = \"aaa\";\r\n        Observable.just(str).map(new Func1<String, String>() {\r\n                    @Override\r\n                    public String call(String s) {\r\n                        Log.i(\"====\", \"s == \" + s);\r\n                        if (\"aaa\".equals(s)) throw new RuntimeException(s);\r\n                        return s + \"123\";\r\n                    }\r\n                }).retryWhen(new Func1<Observable<? extends Throwable>, Observable<?>>() {\r\n                    @Override\r\n                    public Observable<?> call(Observable<? extends Throwable> observable) {\r\n                        return observable.zipWith(Observable.range(1, 4), new Func2<Throwable, Integer, Integer>() {\r\n                            @Override\r\n                            public Integer call(Throwable throwable, Integer i) {\r\n                                str = \"ggg\";\r\n                                return i;\r\n                            }\r\n                        }).flatMap(new Func1<Integer, Observable<? extends Long>>() {\r\n                            @Override\r\n                            public Observable<? extends Long> call(Integer retryCount) {\r\n                                return Observable.timer(1, TimeUnit.SECONDS);\r\n                            }\r\n                        });\r\n                    }\r\n                }).subscribe(new Action1<String>() {\r\n                    @Override\r\n                    public void call(String s) {\r\n                        Log.i(\"====k\", \"s = \" + s);\r\n                    }\r\n                }, new Action1<Throwable>() {\r\n                    @Override\r\n                    public void call(Throwable throwable) {\r\n                        Log.i(\"====\", \"throwable = \" + throwable.getMessage());\r\n                    }\r\n                });\r\n```\r\nIn my opinion，it should log\r\n```\r\naaa\r\nggg\r\nggg\r\n...\r\n```\r\nbut in fact it always log\r\n```\r\naaa\r\naaa\r\naaa\r\n...\r\n```\r\nwhy?"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/260120756","html_url":"https://github.com/ReactiveX/RxJava/issues/4840#issuecomment-260120756","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/4840","id":260120756,"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-12T12:59:01Z","updated_at":"2016-11-12T12:59:01Z","body":"Let me illustrate the situation with a classical example program:\r\n\r\n```java\r\npublic class Example {\r\n    static String str;\r\n\r\n    public static void main(String[] args) {\r\n        str = \"aaa\";\r\n\r\n        String local = str;\r\n\r\n        str = \"ggg\";\r\n\r\n        System.out.println(local);\r\n        System.out.println(local);\r\n        System.out.println(local);\r\n    }\r\n}\r\n```\r\n\r\nCan you tell what this program prints to the console?"}}
{"actor":{"display_login":"akarnokd"}}