diff --git a/Sources/NIO/Codec.swift b/Sources/NIO/Codec.swift index d716585790b..67b5156113d 100644 --- a/Sources/NIO/Codec.swift +++ b/Sources/NIO/Codec.swift @@ -99,7 +99,6 @@ extension ByteToMessageDecoder { /// Calls `decode` until there is nothing left to decode. public func channelRead(ctx: ChannelHandlerContext, data: NIOAny) { var buffer = self.unwrapInboundIn(data) - if self.cumulationBuffer != nil { self.cumulationBuffer!.write(buffer: &buffer) buffer = self.cumulationBuffer! diff --git a/Sources/NIO/EventLoopFuture.swift b/Sources/NIO/EventLoopFuture.swift index 482d20e84c4..123e946697b 100644 --- a/Sources/NIO/EventLoopFuture.swift +++ b/Sources/NIO/EventLoopFuture.swift @@ -322,7 +322,7 @@ public struct EventLoopPromise { /// /// This means that for any `EventLoopFuture` that your code did not create itself (via /// `EventLoopPromise.futureResult`), use of `hopTo` is **strongly encouraged** to help guarantee thread-safety. It -/// should only be elided when thread-safety is proved to be not needed. +/// should only be elided when thread-safety is provably not needed. /// /// The "thread affinity" of `EventLoopFuture`s is critical to writing safe, performant concurrent code without /// boilerplate. It allows you to avoid needing to write or use locks in your own code, instead using the natural diff --git a/Sources/NIOChatServer/main.swift b/Sources/NIOChatServer/main.swift index cbfb4a2d0b5..e24df67881a 100644 --- a/Sources/NIOChatServer/main.swift +++ b/Sources/NIOChatServer/main.swift @@ -177,11 +177,10 @@ let channel = try { () -> Channel in } }() -if let localAddress = channel.localAddress { - print("ChatServer started and listening on \(localAddress)") -} else { - print("ChatServer started but the address could not be determined.") +guard let localAddress = channel.localAddress else { + fatalError("Address was unable to bind. Please check that the socket was not closed or that the address family was understood.") } +print("Server started and listening on \(localAddress)") // This will never unblock as we don't close the ServerChannel. try channel.closeFuture.wait() diff --git a/Sources/NIOHTTP1Server/main.swift b/Sources/NIOHTTP1Server/main.swift index 0830860c69d..82873327c78 100644 --- a/Sources/NIOHTTP1Server/main.swift +++ b/Sources/NIOHTTP1Server/main.swift @@ -498,11 +498,10 @@ let channel = try { () -> Channel in } }() -if let localAddress = channel.localAddress { - print("Server started and listening on \(localAddress), htdocs path \(htdocs)") -} else { - print("Server started but the address could not be determined, htdocs path \(htdocs)") +guard let localAddress = channel.localAddress else { + fatalError("Address was unable to bind. Please check that the socket was not closed or that the address family was understood.") } +print("Server started and listening on \(localAddress), htdocs path \(htdocs)") // This will never unblock as we don't close the ServerChannel try channel.closeFuture.wait() diff --git a/Sources/NIOWebSocketServer/main.swift b/Sources/NIOWebSocketServer/main.swift index 83131f765d6..f1a37ba4956 100644 --- a/Sources/NIOWebSocketServer/main.swift +++ b/Sources/NIOWebSocketServer/main.swift @@ -264,11 +264,10 @@ let channel = try { () -> Channel in } }() -if let localAddress = channel.localAddress { - print("Server started and listening on \(localAddress)") -} else { - print("Server started but the address could not be determined.") +guard let localAddress = channel.localAddress else { + fatalError("Address was unable to bind. Please check that the socket was not closed or that the address family was understood.") } +print("Server started and listening on \(localAddress)") // This will never unblock as we don't close the ServerChannel try channel.closeFuture.wait()