Skip to content

Commit 5fb73c8

Browse files
committed
Removed Handshake promise as it is not used
1 parent e0698d4 commit 5fb73c8

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Sources/AsyncHTTPClient/ConnectionPool.swift

+2-9
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,11 @@ final class ConnectionPool {
414414

415415
private func makeConnection(on eventLoop: EventLoop) -> EventLoopFuture<Connection> {
416416
self.activityPrecondition(expected: [.opened])
417-
let handshakePromise = eventLoop.makePromise(of: Void.self)
418417
let address = HTTPClient.resolveAddress(host: self.key.host, port: self.key.port, proxy: self.configuration.proxy)
419418
let bootstrap : NIOClientTCPBootstrap
420419
do {
421420
bootstrap = try makeHTTPClientBootstrapBase(on: eventLoop)
422421
} catch {
423-
handshakePromise.fail(error)
424422
return eventLoop.makeFailedFuture(error)
425423
}
426424

@@ -433,10 +431,8 @@ final class ConnectionPool {
433431
}
434432

435433
return channel.flatMap { channel -> EventLoopFuture<ConnectionPool.Connection> in
436-
handshakePromise.succeed(())
437-
return handshakePromise.futureResult.flatMap {
438-
channel.pipeline.addHTTPClientHandlers(leftOverBytesStrategy: .forwardBytes)
439-
}.map {
434+
435+
channel.pipeline.addHTTPClientHandlers(leftOverBytesStrategy: .forwardBytes).map {
440436
let connection = Connection(key: self.key, channel: channel, parentPool: self.parentPool)
441437
connection.isLeased = true
442438
return connection
@@ -445,9 +441,6 @@ final class ConnectionPool {
445441
self.configureCloseCallback(of: connection)
446442
return connection
447443
}.flatMapError { error in
448-
// This promise may not have been completed if we reach this
449-
// so we fail it to avoid any leak
450-
handshakePromise.fail(error)
451444
let action = self.parentPool.connectionProvidersLock.withLock {
452445
self.stateLock.withLock {
453446
self.state.failedConnectionAction()

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,11 @@ class HTTPClientTests: XCTestCase {
10941094
}
10951095

10961096
func testStressGetClose() throws {
1097-
guard !(self.clientGroup is NIOTSEventLoopGroup) else {
1098-
XCTFail("Disabled test as it crashes");
1099-
return
1097+
if #available(OSX 10.14, iOS 12.0, tvOS 12.0, watchOS 6.0, *) {
1098+
guard !(self.clientGroup is NIOTSEventLoopGroup) else {
1099+
XCTFail("Disabled test as it crashes");
1100+
return
1101+
}
11001102
}
11011103
let httpBin = HTTPBin(ssl: false)
11021104
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(self.clientGroup),

0 commit comments

Comments
 (0)