File tree 2 files changed +22
-6
lines changed
main/java/io/reactivex/rxjava3/internal/operators/single
test/java/io/reactivex/rxjava3/internal/operators/single
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -113,11 +113,7 @@ public void onError(Throwable e) {
113
113
114
114
@ Override
115
115
public void run () {
116
- Disposable d = get ();
117
- if (d != DisposableHelper .DISPOSED && compareAndSet (d , DisposableHelper .DISPOSED )) {
118
- if (d != null ) {
119
- d .dispose ();
120
- }
116
+ if (DisposableHelper .dispose (this )) {
121
117
SingleSource <? extends T > other = this .other ;
122
118
if (other == null ) {
123
119
downstream .onError (new TimeoutException (timeoutMessage (timeout , unit )));
Original file line number Diff line number Diff line change 28
28
import io .reactivex .rxjava3 .functions .Action ;
29
29
import io .reactivex .rxjava3 .observers .TestObserver ;
30
30
import io .reactivex .rxjava3 .plugins .RxJavaPlugins ;
31
- import io .reactivex .rxjava3 .schedulers .TestScheduler ;
31
+ import io .reactivex .rxjava3 .schedulers .* ;
32
32
import io .reactivex .rxjava3 .subjects .*;
33
33
import io .reactivex .rxjava3 .testsupport .TestHelper ;
34
34
@@ -255,4 +255,24 @@ protected void subscribeActual(@NonNull SingleObserver<? super @NonNull Integer>
255
255
256
256
assertTrue (d .isDisposed ());
257
257
}
258
+
259
+ @ Test
260
+ public void timeoutWithZero () throws InterruptedException {
261
+ int n = 10_000 ;
262
+ Scheduler sch = Schedulers .single ();
263
+ for (int i = 0 ; i < n ; i ++) {
264
+ final int y = i ;
265
+ final CountDownLatch latch = new CountDownLatch (1 );
266
+ Disposable d = Single .never ()
267
+ .timeout (0 , TimeUnit .NANOSECONDS , sch )
268
+ .subscribe (v -> {}, e -> {
269
+ //System.out.println("timeout " + y);
270
+ latch .countDown ();
271
+ });
272
+ if (!latch .await (2 , TimeUnit .SECONDS )) {
273
+ System .out .println (d + " " + sch );
274
+ throw new IllegalStateException ("Timeout did not work at y = " + y );
275
+ }
276
+ }
277
+ }
258
278
}
You can’t perform that action at this time.
0 commit comments