Skip to content

Commit b1cc1cf

Browse files
author
Alexis Oyama
committed
fix(request): Removed lock from loadRequests and add additional protection for 500
1 parent fa63cc8 commit b1cc1cf

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

Leanplum-SDK/Classes/LPRequestStorage.m

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,20 @@ - (void)saveRequests:(NSMutableArray *)requests
124124
*/
125125
- (NSMutableArray *)loadRequests
126126
{
127-
@synchronized (self) {
128-
NSData *requestData = [NSData dataWithContentsOfFile:self.documentsFilePath];
129-
if (requestData) {
130-
NSError *error = nil;
131-
NSMutableArray *requests = [NSPropertyListSerialization
132-
propertyListWithData:requestData
133-
options:NSPropertyListMutableContainers
134-
format:NULL error:&error];
135-
if (error) {
136-
LPLog(LPDebug, @"Error in loading requets: %@", error);
137-
} else {
138-
LPLog(LPDebug, @"Loaded %lu requests", (unsigned long) requests.count);
139-
}
140-
141-
return requests;
127+
NSData *requestData = [NSData dataWithContentsOfFile:self.documentsFilePath];
128+
if (requestData) {
129+
NSError *error = nil;
130+
NSMutableArray *requests = [NSPropertyListSerialization
131+
propertyListWithData:requestData
132+
options:NSPropertyListMutableContainers
133+
format:NULL error:&error];
134+
if (error) {
135+
LPLog(LPDebug, @"Error in loading requets: %@", error);
136+
} else {
137+
LPLog(LPDebug, @"Loaded %lu requests", (unsigned long) requests.count);
142138
}
139+
140+
return requests;
143141
}
144142

145143
return [NSMutableArray new];

Leanplum-SDK/Classes/LeanplumRequest.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,11 @@ - (void)sendNow:(BOOL)async
369369
NSInteger httpStatusCode = completedOperation.HTTPStatusCode;
370370
if (httpStatusCode == 408
371371
|| (httpStatusCode >= 500 && httpStatusCode < 600)
372-
|| err.code == kCFURLErrorCannotConnectToHost
373-
|| err.code == kCFURLErrorDNSLookupFailed
374-
|| err.code == kCFURLErrorNotConnectedToInternet
375-
|| err.code == kCFURLErrorTimedOut) {
372+
|| err.code == NSURLErrorBadServerResponse
373+
|| err.code == NSURLErrorCannotConnectToHost
374+
|| err.code == NSURLErrorDNSLookupFailed
375+
|| err.code == NSURLErrorNotConnectedToInternet
376+
|| err.code == NSURLErrorTimedOut) {
376377
NSLog(@"Leanplum: %@", err);
377378
[LeanplumRequest pushUnsentRequests:requestsToSend];
378379
} else {

0 commit comments

Comments
 (0)