From c7d0a6f672dbfa028f9112086ce1e07e1219c571 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Thu, 20 Jun 2024 11:34:16 +0100 Subject: [PATCH] Swift 6 concurrency fixes (#481) --- Sources/PerformanceTest/main.swift | 1 - Tests/HummingbirdCoreTests/HTTP2Tests.swift | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/PerformanceTest/main.swift b/Sources/PerformanceTest/main.swift index fdbf477ce..f0a43fa52 100644 --- a/Sources/PerformanceTest/main.swift +++ b/Sources/PerformanceTest/main.swift @@ -23,7 +23,6 @@ let port = Environment.shared.get("SERVER_PORT", as: Int.self) ?? 8080 // create app let elg = MultiThreadedEventLoopGroup(numberOfThreads: 4) -defer { try? elg.syncShutdownGracefully() } var router = Router() // number of raw requests // ./wrk -c 128 -d 15s -t 8 http://localhost:8080 diff --git a/Tests/HummingbirdCoreTests/HTTP2Tests.swift b/Tests/HummingbirdCoreTests/HTTP2Tests.swift index 81a8e2aca..333317dfa 100644 --- a/Tests/HummingbirdCoreTests/HTTP2Tests.swift +++ b/Tests/HummingbirdCoreTests/HTTP2Tests.swift @@ -45,9 +45,16 @@ class HummingBirdHTTP2Tests: XCTestCase { eventLoopGroupProvider: .shared(eventLoopGroup), configuration: .init(tlsConfiguration: tlsConfiguration) ) - defer { try? httpClient.syncShutdown() } - let response = try await httpClient.get(url: "https://localhost:\(port)/").get() + let response: HTTPClientResponse + do { + let request = HTTPClientRequest(url: "https://localhost:\(port)/") + response = try await httpClient.execute(request, deadline: .now() + .seconds(30)) + } catch { + try? await httpClient.shutdown() + throw error + } + try await httpClient.shutdown() XCTAssertEqual(response.status, .ok) } }