Skip to content

Fix GoogleUtilities nullability regressions #2079

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

Merged
merged 3 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GoogleUtilities.podspec
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion GoogleUtilities/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
8 changes: 4 additions & 4 deletions GoogleUtilities/Network/GULNetworkURLSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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];
Expand Down
19 changes: 11 additions & 8 deletions GoogleUtilities/Network/Private/GULNetworkURLSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error should also be nullable too, no?

typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *response,
NSData *data,
Expand All @@ -41,19 +43,20 @@ typedef void (^GULNetworkSystemCompletionHandler)(void);
completionHandler:(GULNetworkSystemCompletionHandler)completionHandler;

/// Initializes with logger delegate.
- (instancetype)initWithNetworkLoggerDelegate:(id<GULNetworkLoggerDelegate>)networkLoggerDelegate
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNetworkLoggerDelegate:
(nullable id<GULNetworkLoggerDelegate>)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
completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
- (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
completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
- (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request
completionHandler:(GULNetworkURLSessionCompletionHandler)handler;

NS_ASSUME_NONNULL_END
@end