-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Could Mono.block(Duration timeout)
throw java.util.concurrent.TimeoutException
?
#2267
Comments
|
Note that Mono.never()
.timeout(Duration.ofSeconds(1))
.block(); Throws a This would at least bring consistency in how to deal with timeout exceptions in blocking code: try {
longMono.block();
}
catch (SpecificRuntimeException sre) {
//do something specific
}
catch (RuntimeException e) {
if (Exceptions.unwrap(e) instanceof TimeoutException) {
//deal with timeout
}
else {
//generic exception
}
} |
Working in Kotlin, so I'd forgotten about the checked / unchecked problem. Though I guess it's a breaking change anyway as people might have code expecting an I don't really have a clear solution, just wanted to raise it as something that confused me as a reactor newbie. |
I'm inclined to leave it as is. The breaking change (or the breaking behavior that I suggested above) are IMO not worth it, especially considering that |
Mono.block(Duration timeout)
currently throwsIllegalStateException
if the timeout expires. This seems odd as a) it isn't an illegal state, it's a perfectly possible state that we're explicitly anticipating and b) the more correctjava.util.concurrent.TimeoutException
is thrown in similar circumstances whenMono.timeout(Duration timeout).subscribe()
times out.The code that throws the
IllegalStateException
is:reactor-core/reactor-core/src/main/java/reactor/core/publisher/BlockingSingleSubscriber.java
Line 123 in 232fe2e
The text was updated successfully, but these errors were encountered: