-
Couldn't load subscription status.
- Fork 25.6k
Fix RestCancellableNodeClientTests.testConcurrentExecuteAndClose() #129294
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 2 commits
b14cf47
15708f4
114be1f
533ec6c
0d663d6
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 |
|---|---|---|
|
|
@@ -303,6 +303,10 @@ public void addCloseListener(ActionListener<Void> listener) { | |
| // if the channel is already closed, the listener gets notified immediately, from the same thread. | ||
| if (open.get() == false) { | ||
| listener.onResponse(null); | ||
| // Handle scenario where awaitClose() was called before any calls to addCloseListener(), this ensures closeLatch is pulled. | ||
| if (closeListener.isDone() == false) { | ||
|
||
| closeListener.onResponse(ActionListener.noop()); | ||
| } | ||
| } else { | ||
| assertFalse("close listener already set, only one is allowed!", closeListener.isDone()); | ||
| closeListener.onResponse(ActionListener.assertOnce(listener)); | ||
|
|
||
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.
Ah good point, but then could we achieve the same thing by dropping the whole
if (open.get() == false)and always callingcloseListener.onResponse(ActionListener.assertOnce(listener));? I guess that doesn't guarantee to completelisteneron the calling thread in that case, not sure if this is important.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
testChannelAlreadyClosed()can fail on the unexpectedRestCancellableNodeClient.getNumChannels()value if a listener is completed async. I can update this test and refactorTestHttpChannelto support waiting for thecloseLatchto get pulled after previously callingclose(). Right now you can't just callawaitClose()since it tries to first callclose()which will fail since the atomic has already been set.I'll try to simplify
TestHttpChannel.addCloseListener()to address this comment and the other comment below, adjusting the existing tests andTestHttpChannelas needed.