Rxjava: an illegalargumentexception is thrown when the “first” operator is used

When I use the observable. First () operator, an illegalargumentexception message appears, saying "the sequence contains too many elements."

This is a simplified test code that can reproduce exceptions:

Subject<Integer, Integer> subject = BehaviorSubject.create();

subject.first()
       .subscribe(integer -> subject.onNext(1));

subject.onNext(0);

These codes are extracted from a very complex real project. I don't think I can easily explain why I need to do this strange thing

So I just want to ask one question: is this an error in rxjava or is my own usage incorrect?

If it is not used correctly, I think I need to rewrite the logic to avoid this code

Thank you.

resolvent:

There is a known bug with import operator (used first), which has a reentry problem. This fix will be included in the next version 1.0.15. Sorry, there is no ETA

By the way, why do you do this in your code if there is no such error? Do you want to signal other subscribers?

edit

resolvent:

Any operator that performs serialization can be used to resolve errors. Perhaps the easiest way is to use behaviorsubject. Create(). Toserialized()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>