File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -109,10 +109,7 @@ extension URLSession._TaskRegistry {
109
109
///
110
110
/// - Note: It is a programming error to pass a task that isn't registered.
111
111
/// - Note: This must **only** be accessed on the owning session's work queue.
112
- func behaviour( for task: URLSessionTask ) -> _Behaviour {
113
- guard let b = behaviours [ task. taskIdentifier] else {
114
- fatalError ( " Trying to access a behaviour for a task that in not in the registry. " )
115
- }
116
- return b
112
+ func behaviour( for task: URLSessionTask ) -> _Behaviour ? {
113
+ return behaviours [ task. taskIdentifier]
117
114
}
118
115
}
Original file line number Diff line number Diff line change @@ -557,13 +557,16 @@ internal extension URLSession {
557
557
558
558
func behaviour( for task: URLSessionTask ) -> _TaskBehaviour {
559
559
switch taskRegistry. behaviour ( for: task) {
560
- case . dataCompletionHandler( let c) : return . dataCompletionHandler( c)
561
- case . downloadCompletionHandler( let c) : return . downloadCompletionHandler( c)
562
- case . callDelegate:
560
+ case . dataCompletionHandler( let c) ? : return . dataCompletionHandler( c)
561
+ case . downloadCompletionHandler( let c) ? : return . downloadCompletionHandler( c)
562
+ case . callDelegate? :
563
563
guard let d = delegate as? URLSessionTaskDelegate else {
564
564
return . noDelegate
565
565
}
566
566
return . taskDelegate( d)
567
+ case . none:
568
+ NSLog ( " Trying to access a behaviour for a task that in not in the registry. " )
569
+ return . noDelegate
567
570
}
568
571
}
569
572
}
You can’t perform that action at this time.
0 commit comments