Skip to content

Commit 61d2db7

Browse files
committed
[Test] Fix AlamofireTests where task captures downloadRequest via configure.
1 parent 75223b6 commit 61d2db7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

SwiftTaskTests/AlamofireTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ class AlamofireTests: _TestCase
219219
}
220220

221221
// configure cancel for cleanup after reject or task.cancel()
222-
configure.cancel = {
223-
downloadRequst.cancel()
224-
return
222+
// NOTE: use weak to let task NOT CAPTURE downloadRequst via configure
223+
configure.cancel = { [weak downloadRequst] in
224+
if let downloadRequst = downloadRequst {
225+
downloadRequst.cancel()
226+
}
225227
}
226228

227229
} // end of 1st task definition (NOTE: don't chain with `then` or `catch` for 1st task cancellation)

0 commit comments

Comments
 (0)