@@ -33,7 +33,7 @@ open class URLSessionTask : NSObject, NSCopying {
33
33
internal var suspendCount = 1
34
34
internal var session : URLSessionProtocol ! //change to nil when task completes
35
35
internal let body : _Body
36
- fileprivate var _protocol : URLProtocol ! = nil
36
+ fileprivate var _protocol : URLProtocol ? = nil
37
37
private let syncQ = DispatchQueue ( label: " org.swift.URLSessionTask.SyncQ " )
38
38
39
39
/// All operations must run on this queue.
@@ -178,8 +178,8 @@ open class URLSessionTask : NSObject, NSCopying {
178
178
self . workQueue. async {
179
179
let urlError = URLError ( _nsError: NSError ( domain: NSURLErrorDomain, code: NSURLErrorCancelled, userInfo: nil ) )
180
180
self . error = urlError
181
- self . _protocol. stopLoading ( )
182
- self . _protocol. client? . urlProtocol ( self . _protocol, didFailWithError: urlError)
181
+ self . _protocol? . stopLoading ( )
182
+ self . _protocol? . client? . urlProtocol ( self . _protocol! , didFailWithError: urlError)
183
183
}
184
184
}
185
185
}
@@ -235,7 +235,7 @@ open class URLSessionTask : NSObject, NSCopying {
235
235
236
236
if self . suspendCount == 1 {
237
237
self . workQueue. async {
238
- self . _protocol. stopLoading ( )
238
+ self . _protocol? . stopLoading ( )
239
239
}
240
240
}
241
241
}
@@ -250,7 +250,7 @@ open class URLSessionTask : NSObject, NSCopying {
250
250
self . updateTaskState ( )
251
251
if self . suspendCount == 0 {
252
252
self . workQueue. async {
253
- self . _protocol. startLoading ( )
253
+ self . _protocol? . startLoading ( )
254
254
}
255
255
}
256
256
}
0 commit comments