Skip to content

Commit 58c68e9

Browse files
committed
fix: Failing refresh causing crashes
1 parent 3c313fd commit 58c68e9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Sources/GoodNetworking/Interception/AuthenticationInterceptor.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ public final class AuthenticationInterceptor<AuthenticatorType: Authenticator>:
2323

2424
public func adapt(urlRequest: inout URLRequest) async throws(NetworkError) {
2525
await lock.lock()
26+
defer { lock.unlock() }
27+
2628
if let credential = await authenticator.getCredential() {
2729
if let refreshableCredential = credential as? RefreshableCredential, refreshableCredential.requiresRefresh {
2830
try await refresh(credential: credential)
2931
}
3032
try await authenticator.apply(credential: credential, to: &urlRequest)
3133
}
32-
lock.unlock()
3334
}
3435

3536
public func retry(urlRequest: inout URLRequest, for session: NetworkSession, dueTo error: NetworkError) async throws(NetworkError) -> RetryResult {

0 commit comments

Comments
 (0)