-
Notifications
You must be signed in to change notification settings - Fork 182
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
Do not cancel subscription on BlockingIterable#hasNext(long, TimeUnit) #3128
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This makes sure that if this method, or in extend next(long, TimeUnit) is called and times out, the caller is able to retry the operation and also the upstream source will not be cancelled. In the context of a Blocking Streaming server, this means that if a timeout is thrown on the incoming request, the outgoing response can still be modified since the underlying socket will not be immediately closed. It also aligns the semantics with Single#toFuture where a blocking get with a timeout on the future also does not cancel the upstream Single. A (temporary) system property is introduced which allows to fall back to the old behavior should incompatibilities be discovered in the wild. A note for the reader who wonders how to close the subscription now: the close() method always did cancel the subscription and continues to do so.
daschl
commented
Dec 5, 2024
servicetalk-concurrent/src/main/java/io/servicetalk/concurrent/BlockingIterable.java
Outdated
Show resolved
Hide resolved
...-concurrent-api/src/main/java/io/servicetalk/concurrent/api/PublisherAsBlockingIterable.java
Outdated
Show resolved
Hide resolved
servicetalk-concurrent/src/main/java/io/servicetalk/concurrent/BlockingIterable.java
Outdated
Show resolved
Hide resolved
idelpivnitskiy
approved these changes
Dec 6, 2024
mgodave
reviewed
Dec 6, 2024
@@ -72,6 +72,12 @@ public BlockingIterator<T> iterator() { | |||
} | |||
|
|||
private static final class SubscriberAndIterator<T> implements Subscriber<T>, BlockingIterator<T> { | |||
/** |
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.
It might be worth adding that this is false
by default, ie not enabled.
mgodave
approved these changes
Dec 6, 2024
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 presented this offline, I think this is the correct behavior.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes sure that if this method, or indirectly
next(long, TimeUnit)
is called and times out, the caller is able to retry the operation and also the upstream source will not be cancelled.In the context of a
BlockingStreaming
server, this means that if a timeout is thrown on the incoming request, the outgoing response can still be modified since the underlying socket will not be immediately closed.It also aligns the semantics with
Single#toFuture
where a blocking get with a timeout on the future also does not cancel the upstreamSingle
.A (temporary) system property is introduced which allows to fall back to the old behavior should incompatibilities be discovered in the wild.
A note for the reader who wonders how to close the subscription now: the close() method always did cancel the subscription and continues to do so. To make sure
forEach
also adheres to the iterator contract it uses it is now wrapped intry-with-resource
.