make all removals go through the RemovableChannelHandler API (#815)

Motivation:

Some of the ChannelPipeline removal methods did not go through the
RemovableChannelHandler API.

Modifications:

make all removal APIs go through the RemovableChannelHandler API

Result:

fewer bugs
This commit is contained in:
Johannes Weiss authored and GitHub committed 2019-02-12 19:06:39 +01:00
1 parent c6c1f84459
commit 6e7a3de8e8
7 files changed
+97 -18

No files matched your search

@@ -103,7 +103,7 @@ public class WebSocketFrameDecoderTest: XCTestCase {
private func swapDecoder(for handler: ChannelHandler) {
// We need to insert a decoder that doesn't do error handling. We still insert
// an encoder because we want to fail gracefully if a frame is written.
XCTAssertNoThrow(try self.decoderChannel.pipeline.context(handlerType: ByteToMessageHandler<WebSocketFrameDecoder>.self).flatMapThrowing {
let f = self.decoderChannel.pipeline.context(handlerType: ByteToMessageHandler<WebSocketFrameDecoder>.self).flatMapThrowing {
if let handler = $0.handler as? RemovableChannelHandler {
return handler
} else {
@@ -111,7 +111,12 @@ public class WebSocketFrameDecoderTest: XCTestCase {
}
}.flatMap {
self.decoderChannel.pipeline.remove(handler: $0)
}.flatMap {
}
// we need to run the event loop here because removal is not synchronous
(self.decoderChannel.eventLoop as! EmbeddedEventLoop).run()
XCTAssertNoThrow(try f.flatMap {
self.decoderChannel.pipeline.add(handler: handler)
}.wait())
}