Enable strict concurrency checking for NIOHTTP1Server (#3132)

### Motivation:

To ensure `NIOHTTP1Server` concurrency safety.

### Modifications:

* Enable strict concurrency checking in the package manifest.
* User synchronous operations in pipeline configurations

### Result:

Builds will warn and CI will fail if regressions are introduced.
This commit is contained in:
Rick Newton-Rogers authored and GitHub committed 2025-03-06 14:58:02 +00:00
1 parent 4f2d42f83f
commit de47bf8ba5
3 files changed
+10 -8

No files matched your search

+2 -1
View File
@@ -319,7 +319,8 @@ let package = Package(
"NIOHTTP1",
"NIOConcurrencyHelpers",
],
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: strictConcurrencySettings
),
.executableTarget(
name: "NIOHTTP1Client",
+6 -5
View File
@@ -81,11 +81,12 @@ let bootstrap = ClientBootstrap(group: group)
// Enable SO_REUSEADDR.
.channelOption(.socketOption(.so_reuseaddr), value: 1)
.channelInitializer { channel in
channel.pipeline.addHTTPClientHandlers(
position: .first,
leftOverBytesStrategy: .fireError
).flatMap {
channel.pipeline.addHandler(HTTPEchoHandler())
channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.addHTTPClientHandlers(
position: .first,
leftOverBytesStrategy: .fireError
)
try channel.pipeline.syncOperations.addHandler(HTTPEchoHandler())
}
}
defer {
+2 -2
View File
@@ -631,8 +631,8 @@ default:
}
func childChannelInitializer(channel: Channel) -> EventLoopFuture<Void> {
channel.pipeline.configureHTTPServerPipeline(withErrorHandling: true).flatMap {
channel.pipeline.addHandler(HTTPHandler(fileIO: fileIO, htdocsPath: htdocs))
channel.pipeline.configureHTTPServerPipeline(withErrorHandling: true).flatMapThrowing {
try channel.pipeline.syncOperations.addHandler(HTTPHandler(fileIO: fileIO, htdocsPath: htdocs))
}
}