File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed
rxjava-core/src/main/java/rx/operators Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,7 @@ public void onNext(Observable<? extends T> args) {
96
96
this .hasLatest = true ;
97
97
}
98
98
99
- final SafeObservableSubscription sub ;
100
- sub = new SafeObservableSubscription ();
99
+ final SafeObservableSubscription sub = new SafeObservableSubscription ();
101
100
sub .wrap (args .subscribe (new Observer <T >() {
102
101
@ Override
103
102
public void onNext (T args ) {
@@ -110,28 +109,36 @@ public void onNext(T args) {
110
109
111
110
@ Override
112
111
public void onError (Throwable e ) {
112
+ sub .unsubscribe ();
113
+ SafeObservableSubscription s = null ;
113
114
synchronized (gate ) {
114
- sub .unsubscribe ();
115
115
if (latest == id ) {
116
116
SwitchObserver .this .observer .onError (e );
117
- SwitchObserver .this .parent . unsubscribe () ;
117
+ s = SwitchObserver .this .parent ;
118
118
}
119
119
}
120
+ if (s != null ) {
121
+ s .unsubscribe ();
122
+ }
120
123
}
121
124
122
125
@ Override
123
126
public void onCompleted () {
127
+ sub .unsubscribe ();
128
+ SafeObservableSubscription s = null ;
124
129
synchronized (gate ) {
125
- sub .unsubscribe ();
126
130
if (latest == id ) {
127
131
SwitchObserver .this .hasLatest = false ;
128
132
129
133
if (stopped ) {
130
134
SwitchObserver .this .observer .onCompleted ();
131
- SwitchObserver .this .parent . unsubscribe () ;
135
+ s = SwitchObserver .this .parent ;
132
136
}
133
137
}
134
138
}
139
+ if (s != null ) {
140
+ s .unsubscribe ();
141
+ }
135
142
}
136
143
137
144
}));
@@ -150,13 +157,17 @@ public void onError(Throwable e) {
150
157
151
158
@ Override
152
159
public void onCompleted () {
160
+ SafeObservableSubscription s = null ;
153
161
synchronized (gate ) {
154
162
this .stopped = true ;
155
163
if (!this .hasLatest ) {
156
164
this .observer .onCompleted ();
157
- this .parent . unsubscribe () ;
165
+ s = this .parent ;
158
166
}
159
167
}
168
+ if (s != null ) {
169
+ s .unsubscribe ();
170
+ }
160
171
}
161
172
162
173
}
You can’t perform that action at this time.
0 commit comments