-
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
Throw wrapped TimeoutException
on Mono.block*
and Flux.block*
#3733
Throw wrapped TimeoutException
on Mono.block*
and Flux.block*
#3733
Conversation
Throw wrapped `TimeoutException` on `Mono.block*` and `Flux.block*` so that user can use this when timeout instead of digging into IllegalStateException message. Fixes reactor#3709.
String errorMessage = "Timeout on blocking read for " + timeout + " " + unit; | ||
throw new IllegalStateException(errorMessage, new TimeoutException(errorMessage)); |
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.
public T block(Duration timeout) { |
public final T blockFirst(Duration timeout) { |
public final T blockLast(Duration timeout) { |
I checked that Mono#block(timeout), Flux#blockFirst(timeout), Flux#blockLast(timeout)
use this code~!
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.
* If the provided timeout expires, a {@link RuntimeException} is thrown. |
// AS-IS
If the provided timeout expires, a {@link RuntimeException} is thrown.
// TO-BE
If the provided timeout expires, a {@link RuntimeException} is thrown with {@link TimeoutException} as the cause.
(just curiosity) should we enhance document on Mono#block*, Flux#block*
like above?
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.
Yes, please.
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.
✅ update javadoc :)
String errorMessage = "Timeout on blocking read for " + timeout + " " + unit; | ||
throw new IllegalStateException(errorMessage, new TimeoutException(errorMessage)); |
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.
public Optional<T> blockOptional(Duration timeout) { |
I checked that Mono.blockOptional(timeout)
use this code~!
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 @injae-kim ! Great job. Do you mind adding the bit about the cause to the javadocs as you suggested?
String errorMessage = "Timeout on blocking read for " + timeout + " " + unit; | ||
throw new IllegalStateException(errorMessage, new TimeoutException(errorMessage)); |
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.
Yes, please.
@@ -103,7 +104,8 @@ public void timeoutOptionalTimingOut() { | |||
// Using sub-millis timeouts after gh-1734 | |||
assertThatExceptionOfType(IllegalStateException.class) | |||
.isThrownBy(() -> source.blockOptional(Duration.ofNanos(100))) | |||
.withMessage("Timeout on blocking read for 100 NANOSECONDS"); | |||
.withMessage("Timeout on blocking read for 100 NANOSECONDS") | |||
.withCause(new TimeoutException("Timeout on blocking read for 100 NANOSECONDS")); |
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.
Update the Javadoc too
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.
Thank you, @injae-kim 👏
Throw wrapped
TimeoutException
onMono.block*
andFlux.block*
so that user can use this when timeout instead of digging into IllegalStateException message.Fixes #3709.