-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Java] Safely call onError on Subjects #31779
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
Conversation
|
|
||
| public void timeoutHandshakeResponse(long timeout, TimeUnit unit) { | ||
| handshakeTimeout = Executors.newSingleThreadScheduledExecutor(); | ||
| handshakeTimeout.schedule(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this uses an executor to implement the timeout instead of using RxJava's timeout operator?
connectionState.transport.send(handshake).timeout(..., ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably implemented before RxJava was used.
Keeping it as-is so it's easier to backport to 5.0
| private void errorHandshake(Exception error) { | ||
| lock.lock(); | ||
| try { | ||
| // If onError is called on a completed subject the global error handler is called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we could hook the global error handler with our tests and fail if it ever gets called? Would that have been able to catch this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could use something like this:
https://github.com/uber/AutoDispose/blob/2.0.0/test-utils/src/main/java/autodispose2/test/RxErrorsRule.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pointer, adapted something similar for junit 5
Fixes #31491
We should backport this to 5.0.