Skip to content

Commit d5134bb

Browse files
committed
Review nits
1 parent a08ddfd commit d5134bb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/AsyncHTTPClient/ConnectionPool/State Machine/HTTPConnectionPool+HTTP2Connections.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ extension HTTPConnectionPool {
192192
case .active(let conn, let maxStreams, var usedStreams, let lastIdle, let remainingUses):
193193
usedStreams += count
194194
precondition(usedStreams <= maxStreams, "tried to lease a connection which is not available")
195+
precondition(remainingUses.map { $0 >= count } ?? true, "tried to lease streams from a connection which does not have enough remaining streams")
195196
self.state = .active(conn, maxStreams: maxStreams, usedStreams: usedStreams, lastIdle: lastIdle, remainingUses: remainingUses.map { $0 - count })
196197
return conn
197198
}

Sources/AsyncHTTPClient/HTTPClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ public class HTTPClient {
764764
/// - Precondition: The value must be greater than zero.
765765
public var maximumUsesPerConnection: Int? {
766766
willSet {
767-
if let newValue = newValue {
768-
precondition(newValue > 0, "maximumUsesPerConnection must be greater than zero or nil")
767+
if let newValue = newValue, newValue <= 0 {
768+
fatalError("maximumUsesPerConnection must be greater than zero or nil")
769769
}
770770
}
771771
}

0 commit comments

Comments
 (0)