-
Notifications
You must be signed in to change notification settings - Fork 3.9k
core: Added changes to DelayedStream.setStream() should cancel the provided stream if not using it #11969
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
base: master
Are you sure you want to change the base?
core: Added changes to DelayedStream.setStream() should cancel the provided stream if not using it #11969
Changes from all commits
270567d
072d033
8ac9678
cac52d4
00eb166
8cd4d5a
2295bbe
9e6ece3
77216bf
d28fcb2
eeded6f
036cd41
61bb878
3a35a76
fa77210
129e747
f828a3c
8c7cf53
8879e94
920c384
0ab9e11
b7df168
58f39fa
013948d
a2220eb
67b2f3a
696dd52
6beb245
17e6b41
d1602ad
163c958
11adf6f
529a75e
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 |
---|---|---|
|
@@ -125,11 +125,21 @@ public void appendTimeoutInsight(InsightBuilder insight) { | |
@CheckReturnValue | ||
final Runnable setStream(ClientStream stream) { | ||
ClientStreamListener savedListener; | ||
ClientStream oldStream = null; | ||
boolean cancelOldStream = false; | ||
|
||
synchronized (this) { | ||
// If realStream != null, then either setStream() or cancel() has been called. | ||
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. Has this changed ? 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. No, added back the removed comment, it was accidentally missed while updating the code, but the logic still holds. if realStream() != null, it means setStream() was called, and if listener !=null, the old stream may have been cancelled. |
||
if (realStream != null) { | ||
oldStream = realStream; | ||
cancelOldStream = listener != null; | ||
} | ||
if (oldStream != null && !cancelOldStream) { | ||
return null; | ||
} | ||
if (cancelOldStream) { | ||
oldStream.cancel(Status.CANCELLED.withDescription("Replaced by a new Stream")); | ||
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. No. We've already chosen a stream. We can't change to a different stream now. I don't understand why this is being done this way, especially since #1537 said that the stream passed into this function would be the one cancelled. |
||
} | ||
setRealStream(checkNotNull(stream, "stream")); | ||
savedListener = listener; | ||
if (savedListener == null) { | ||
|
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 need to look into why this change was made. It looks like it delays registering the stream in pendingStreams to avoid createRealStream() from being called. We may need to double-check the transport state here, because there are state checks before
createPendingStream()
that are now out-of-date.