From f1e1187b917546afecf24f9df3460208c4b15a39 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Wed, 14 Nov 2018 12:05:29 -0800 Subject: [PATCH 1/3] Fix GoogleUtility nullability regressions --- GoogleUtilities.podspec | 2 +- GoogleUtilities/CHANGELOG.md | 4 +++- GoogleUtilities/Network/GULNetworkURLSession.m | 8 ++++---- .../Network/Private/GULNetworkURLSession.h | 13 ++++++++----- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/GoogleUtilities.podspec b/GoogleUtilities.podspec index e0d4952e104..0e2d2be7436 100644 --- a/GoogleUtilities.podspec +++ b/GoogleUtilities.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GoogleUtilities' - s.version = '5.3.5' + s.version = '5.3.6' s.summary = 'Google Utilities for iOS (plus community support for macOS and tvOS)' s.description = <<-DESC diff --git a/GoogleUtilities/CHANGELOG.md b/GoogleUtilities/CHANGELOG.md index fc528a801af..b9de9b54caf 100644 --- a/GoogleUtilities/CHANGELOG.md +++ b/GoogleUtilities/CHANGELOG.md @@ -1,9 +1,11 @@ # Unreleased +# 5.3.6 +- Fix nullability issues. (#2079) + # 5.3.5 - Fixed an issue where GoogleUtilities would leak non-background URL sessions. (#2061) - - Fixed a crash caused due to `NSURLConnection` delegates being wrapped in an `NSProxy`. (#1936) diff --git a/GoogleUtilities/Network/GULNetworkURLSession.m b/GoogleUtilities/Network/GULNetworkURLSession.m index 3ecc36ee014..3f0ac76e9db 100644 --- a/GoogleUtilities/Network/GULNetworkURLSession.m +++ b/GoogleUtilities/Network/GULNetworkURLSession.m @@ -102,8 +102,8 @@ + (void)handleEventsForBackgroundURLSessionID:(NSString *)sessionID /// Sends an async POST request using NSURLSession for iOS >= 7.0, and returns an ID of the /// connection. -- (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request - completionHandler:(GULNetworkURLSessionCompletionHandler)handler +- (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request + completionHandler:(GULNetworkURLSessionCompletionHandler)handler API_AVAILABLE(ios(7.0)) { // NSURLSessionUploadTask does not work with NSData in the background. // To avoid this issue, write the data to a temporary file to upload it. @@ -180,8 +180,8 @@ - (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request } /// Sends an async GET request using NSURLSession for iOS >= 7.0, and returns an ID of the session. -- (NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request - completionHandler:(GULNetworkURLSessionCompletionHandler)handler +- (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request + completionHandler:(GULNetworkURLSessionCompletionHandler)handler API_AVAILABLE(ios(7.0)) { if (_backgroundNetworkEnabled) { _sessionConfig = [self backgroundSessionConfigWithSessionID:_sessionID]; diff --git a/GoogleUtilities/Network/Private/GULNetworkURLSession.h b/GoogleUtilities/Network/Private/GULNetworkURLSession.h index 94d9cdf1a42..b3a97945715 100644 --- a/GoogleUtilities/Network/Private/GULNetworkURLSession.h +++ b/GoogleUtilities/Network/Private/GULNetworkURLSession.h @@ -18,8 +18,10 @@ #import "GULNetworkLoggerProtocol.h" -typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse *response, - NSData *data, +NS_ASSUME_NONNULL_BEGIN + +typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse * _Nullable response, + NSData * _Nullable data, NSError *error); typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *response, NSData *data, @@ -41,19 +43,20 @@ typedef void (^GULNetworkSystemCompletionHandler)(void); completionHandler:(GULNetworkSystemCompletionHandler)completionHandler; /// Initializes with logger delegate. -- (instancetype)initWithNetworkLoggerDelegate:(id)networkLoggerDelegate +- (instancetype)initWithNetworkLoggerDelegate:(nullable id)networkLoggerDelegate NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; /// Sends an asynchronous POST request and calls the provided completion handler when the request /// completes or when errors occur, and returns an ID of the session/connection. -- (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request +- (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request completionHandler:(GULNetworkURLSessionCompletionHandler)handler; /// Sends an asynchronous GET request and calls the provided completion handler when the request /// completes or when errors occur, and returns an ID of the session. -- (NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request +- (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request completionHandler:(GULNetworkURLSessionCompletionHandler)handler; +NS_ASSUME_NONNULL_END @end From 9eb680cba65a235d5406f390b5f3e7ecf9875878 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Wed, 14 Nov 2018 12:08:34 -0800 Subject: [PATCH 2/3] style --- .../Network/Private/GULNetworkURLSession.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GoogleUtilities/Network/Private/GULNetworkURLSession.h b/GoogleUtilities/Network/Private/GULNetworkURLSession.h index b3a97945715..588fff6f211 100644 --- a/GoogleUtilities/Network/Private/GULNetworkURLSession.h +++ b/GoogleUtilities/Network/Private/GULNetworkURLSession.h @@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN -typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse * _Nullable response, - NSData * _Nullable data, +typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse *_Nullable response, + NSData *_Nullable data, NSError *error); typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *response, NSData *data, @@ -43,20 +43,20 @@ typedef void (^GULNetworkSystemCompletionHandler)(void); completionHandler:(GULNetworkSystemCompletionHandler)completionHandler; /// Initializes with logger delegate. -- (instancetype)initWithNetworkLoggerDelegate:(nullable id)networkLoggerDelegate - NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithNetworkLoggerDelegate: + (nullable id)networkLoggerDelegate NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; /// Sends an asynchronous POST request and calls the provided completion handler when the request /// completes or when errors occur, and returns an ID of the session/connection. - (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request - completionHandler:(GULNetworkURLSessionCompletionHandler)handler; + completionHandler:(GULNetworkURLSessionCompletionHandler)handler; /// Sends an asynchronous GET request and calls the provided completion handler when the request /// completes or when errors occur, and returns an ID of the session. - (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request - completionHandler:(GULNetworkURLSessionCompletionHandler)handler; + completionHandler:(GULNetworkURLSessionCompletionHandler)handler; NS_ASSUME_NONNULL_END @end From 712eead0b802af4d4f48a978956cf31d849fbec7 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Wed, 14 Nov 2018 14:44:17 -0800 Subject: [PATCH 3/3] More missing Nullables --- GoogleUtilities/Network/Private/GULNetworkURLSession.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GoogleUtilities/Network/Private/GULNetworkURLSession.h b/GoogleUtilities/Network/Private/GULNetworkURLSession.h index 588fff6f211..3f9f7f9e14d 100644 --- a/GoogleUtilities/Network/Private/GULNetworkURLSession.h +++ b/GoogleUtilities/Network/Private/GULNetworkURLSession.h @@ -22,11 +22,11 @@ NS_ASSUME_NONNULL_BEGIN typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse *_Nullable response, NSData *_Nullable data, - NSError *error); -typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *response, - NSData *data, + NSError *_Nullable error); +typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *_Nullable response, + NSData *_Nullable data, NSString *sessionID, - NSError *error); + NSError *_Nullable error); typedef void (^GULNetworkSystemCompletionHandler)(void); /// The protocol that uses NSURLSession for iOS >= 7.0 to handle requests and responses.