mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
fix almost all Sendable warnings (#2994)
### Motivation: Opening the `swift-nio` repository made me warning blind because there were always so many trivially fixable warnings about things that were correct but cannot be understood by the compiler. ### Modifications: Fix all the sendable warnings that popped up, except for one test where `NIOLockedValueBox<Thread?>` isn't sendable because `Foundation.Thread` seemingly isn't `Sendable` which is odd. Guessing that'll be fixed on their end. ### Result: - Fewer warnings - Less warning-blindness - More checks
This commit is contained in:
1 parent
1f1e787f0b
commit
6ba8f4f04a
27 files changed
+253
-118
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
//
|
||||
// Copyright (c) 2017-2021 Apple Inc. and the SwiftNIO project authors
|
||||
// Copyright (c) 2017-2024 Apple Inc. and the SwiftNIO project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
@@ -25,6 +25,7 @@ public final class WebSocketProtocolErrorHandler: ChannelInboundHandler {
|
||||
public init() {}
|
||||
|
||||
public func errorCaught(context: ChannelHandlerContext, error: Error) {
|
||||
let loopBoundContext = context.loopBound
|
||||
if let error = error as? NIOWebSocketError {
|
||||
var data = context.channel.allocator.buffer(capacity: 2)
|
||||
data.write(webSocketErrorCode: WebSocketErrorCode(error))
|
||||
@@ -34,6 +35,7 @@ public final class WebSocketProtocolErrorHandler: ChannelInboundHandler {
|
||||
data: data
|
||||
)
|
||||
context.writeAndFlush(Self.wrapOutboundOut(frame)).whenComplete { (_: Result<Void, Error>) in
|
||||
let context = loopBoundContext.value
|
||||
context.close(promise: nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user