-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix for URLSession registers native protocol classes for each new session #1030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for URLSession registers native protocol classes for each new session #1030
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a different mechanism, such as dispatch_once, to ensure they are only added a single time, rather than special casing (and breaking) the API.
Foundation/NSURLProtocol.swift
Outdated
@@ -471,7 +473,7 @@ open class URLProtocol : NSObject { | |||
} | |||
|
|||
internal class func getProtocols() -> [AnyClass]? { | |||
return _registeredProtocolClasses | |||
return _nativeProtocolClasses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to break anyone who registers their protocol classes via the supported APIs, right? Creating a special-case for HTTPURLProtocol does not look like the way to fix this problem. Instead, the protocol classes should be added using a dispatch_once style mechanism, so that they aren't added each time.
@alblue Thanks for the review comments. I have used |
@swift-ci please test |
@@ -191,6 +191,10 @@ open class URLSession : NSObject { | |||
internal let taskRegistry = URLSession._TaskRegistry() | |||
fileprivate let identifier: Int32 | |||
fileprivate var invalidated = false | |||
fileprivate static let registerProtocols: Void = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Void
necessary here?
Thanks @nethraravindran and @alblue @swift-ci please test and merge |
@swift-ci please test and merge |
Some unrelated tests seem to have failed:
|
Looks like the reason is #1043 |
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
No description provided.