-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Throw wrapped TimeoutException
on Mono.block*
and Flux.block*
#3733
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||||||
/* | ||||||||||
* Copyright (c) 2016-2023 VMware Inc. or its affiliates, All Rights Reserved. | ||||||||||
* Copyright (c) 2016-2024 VMware Inc. or its affiliates, All Rights Reserved. | ||||||||||
* | ||||||||||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
* you may not use this file except in compliance with the License. | ||||||||||
|
@@ -18,6 +18,7 @@ | |||||||||
|
||||||||||
import java.util.concurrent.CountDownLatch; | ||||||||||
import java.util.concurrent.TimeUnit; | ||||||||||
import java.util.concurrent.TimeoutException; | ||||||||||
|
||||||||||
import org.reactivestreams.Subscription; | ||||||||||
import reactor.core.Disposable; | ||||||||||
|
@@ -124,7 +125,8 @@ final T blockingGet(long timeout, TimeUnit unit) { | |||||||||
try { | ||||||||||
if (!await(timeout, unit)) { | ||||||||||
dispose(); | ||||||||||
throw new IllegalStateException("Timeout on blocking read for " + timeout + " " + unit); | ||||||||||
String errorMessage = "Timeout on blocking read for " + timeout + " " + unit; | ||||||||||
throw new IllegalStateException(errorMessage, new TimeoutException(errorMessage)); | ||||||||||
Comment on lines
+128
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I checked that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
(just curiosity) should we enhance document on There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. ✅ update javadoc :) |
||||||||||
} | ||||||||||
} | ||||||||||
catch (InterruptedException ex) { | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2017-2023 VMware Inc. or its affiliates, All Rights Reserved. | ||
* Copyright (c) 2017-2024 VMware Inc. or its affiliates, All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -19,6 +19,7 @@ | |
import java.time.Duration; | ||
import java.util.Optional; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Update the Javadoc too |
||
} | ||
|
||
@Test | ||
|
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.
reactor-core/reactor-core/src/main/java/reactor/core/publisher/Mono.java
Line 1851 in bbc9bd4
I checked that
Mono.blockOptional(timeout)
use this code~!