-
Notifications
You must be signed in to change notification settings - Fork 123
Fix bi directional streaming test #405
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
Fix bi directional streaming test #405
Conversation
FWIW the shared state isn't an issue: NIO's multithreading rules mean there is no data race here. |
} | ||
|
||
func didSendRequest(task: HTTPClient.Task<Response>) { | ||
XCTAssert(self.eventLoop.inEventLoop) |
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.
Can we remove this assertion? inEventLoop
is validly allowed to return false negatives, so we shouldn't assert that it won't. We can add preconditionInEventLoop
instead if you want the check.
|
||
let sent = ByteBuffer(integer: index) | ||
writer.write(.byteBuffer(sent)).flatMap { () -> EventLoopFuture<ByteBuffer?> in | ||
XCTAssert(delegateEL.inEventLoop, "Always dispatch back to delegate el") |
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.
Same note here about false positives.
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.
Looks good; nothing beyond Cory's comments.
8277b0f
to
5875377
Compare
Motivation
The
HTTPEchoHandler
has a propertyvar promises: CircularBuffer<EventLoopPromise<Void>>
that is currently accessed without lock from different eventLoops (self.serverGroup
andself.defaultClient.eventLoopGroup
). This in itself may not be a problem. However testing bi directional streaming should not depend on shared promises. Instead the client should write something to an echo server, wait for the body to be echoed and write some more.Changes
Result
No weird shared state in promises between client and server.