Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxIdler throws IllegalStateException when buffer is used #6

Closed
audriusKV opened this issue Jul 20, 2017 · 15 comments
Closed

RxIdler throws IllegalStateException when buffer is used #6

audriusKV opened this issue Jul 20, 2017 · 15 comments

Comments

@audriusKV
Copy link

When RxJava2 operator buffer is used like this:

RxJavaPlugins.setInitIoSchedulerHandler(Rx2Idler.create("Test scheduler"));
PublishSubject subject = PublishSubject.create();

subject
        .buffer(1, TimeUnit.SECONDS, Schedulers.io())
        .subscribe();

RxIdler throws IllegalStateException:

java.lang.IllegalStateException: Already completed
  at com.squareup.rx2.idler.DelegatingIdlingResourceScheduler$ScheduledWork.run(DelegatingIdlingResourceScheduler.java:152)
  at io.reactivex.Scheduler$Worker$PeriodicTask.run(Scheduler.java:371)
  at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
  at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
  at java.lang.Thread.run(Thread.java:764)

If this actual RxIdler issue I can provide project to reproduce this.

@JakeWharton
Copy link
Member

JakeWharton commented Jul 20, 2017 via email

@nhaarman
Copy link

nhaarman commented Jul 29, 2017

The same goes for Observable.interval, but only if initialDelay is set to 0:

Observable.interval(0, 1, SECONDS, Schedulers.computation())
              .subscribe()
W: java.lang.IllegalStateException: Already completed
W:     at com.myapp.DelegatingIdlingResourceScheduler$ScheduledWork.run(DelegatingIdlingResourceScheduler.java:152)
W:     at io.reactivex.Scheduler$Worker$PeriodicTask.run(Scheduler.java:371)
W:     at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
W:     at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
W:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
W:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
W:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
W:     at java.lang.Thread.run(Thread.java:764)

@JakeWharton
Copy link
Member

The fix is trivial but the implications are very complicated so I don't want to make it blindly. Need more time to investigate.

@henorek
Copy link

henorek commented Aug 23, 2017

@JakeWharton Is there a chance that this will be fixed soon?

@JakeWharton
Copy link
Member

JakeWharton commented Aug 24, 2017 via email

@jonasfa
Copy link

jonasfa commented Sep 11, 2017

Is there any known workaround?
@JakeWharton perhaps if you explain what the issue is, somebody will work on it?

@JakeWharton
Copy link
Member

JakeWharton commented Sep 11, 2017 via email

@jonasfa
Copy link

jonasfa commented Sep 11, 2017

@JakeWharton thanks. You also mentioned complicated implications for a possible fix. Do you remember what was that?

@JakeWharton
Copy link
Member

JakeWharton commented Sep 11, 2017 via email

@Maragues
Copy link

Maragues commented Sep 21, 2017

@nhaarman I'm seeing this issue with or without initialDelay.

In the case of interval, the first tick is emitted, but it never goes beyond that. It does print the doAfterNext statement.

In the meantime, I'm using a JUnit rule that I've used in the past, which brings its own issues but at least it doesn't crash in my scenario

You can also check ReactiveX/RxAndroid#149

@philipbjorge
Copy link

Seeing this for sample as well.

@athkalia
Copy link

Any updates on this?

@mseroczynski
Copy link

Any updates?

1 similar comment
@niemandkun
Copy link

niemandkun commented Nov 30, 2018

Any updates?

@larryng
Copy link
Contributor

larryng commented Jan 3, 2019

Made a PR that I believe addresses this issue: #14

Makes the state machine go backwards for periodic work, but AFAICT it should be safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests