Skip to content

Commit ed343bd

Browse files
committed
Removed Handshake promise as it is not used
1 parent 248ad2a commit ed343bd

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Sources/AsyncHTTPClient/ConnectionPool.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,11 @@ final class ConnectionPool {
417417

418418
private func makeConnection(on eventLoop: EventLoop) -> EventLoopFuture<Connection> {
419419
self.activityPrecondition(expected: [.opened])
420-
let handshakePromise = eventLoop.makePromise(of: Void.self)
421420
let address = HTTPClient.resolveAddress(host: self.key.host, port: self.key.port, proxy: self.configuration.proxy)
422421
let bootstrap : NIOClientTCPBootstrap
423422
do {
424423
bootstrap = try makeHTTPClientBootstrapBase(on: eventLoop)
425424
} catch {
426-
handshakePromise.fail(error)
427425
return eventLoop.makeFailedFuture(error)
428426
}
429427

@@ -436,10 +434,8 @@ final class ConnectionPool {
436434
}
437435

438436
return channel.flatMap { channel -> EventLoopFuture<ConnectionPool.Connection> in
439-
handshakePromise.succeed(())
440-
return handshakePromise.futureResult.flatMap {
441-
channel.pipeline.addHTTPClientHandlers(leftOverBytesStrategy: .forwardBytes)
442-
}.map {
437+
438+
channel.pipeline.addHTTPClientHandlers(leftOverBytesStrategy: .forwardBytes).map {
443439
let connection = Connection(key: self.key, channel: channel, parentPool: self.parentPool)
444440
connection.isLeased = true
445441
return connection
@@ -448,9 +444,6 @@ final class ConnectionPool {
448444
self.configureCloseCallback(of: connection)
449445
return connection
450446
}.flatMapError { error in
451-
// This promise may not have been completed if we reach this
452-
// so we fail it to avoid any leak
453-
handshakePromise.fail(error)
454447
let action = self.parentPool.connectionProvidersLock.withLock {
455448
self.stateLock.withLock {
456449
self.state.failedConnectionAction()

Tests/AsyncHTTPClientTests/HTTPClientTests.swift

Lines changed: 5 additions & 3 deletions
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)