Skip to content
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):When a ephemeral session configuration causes an exception, catch try background or return nil. #417

Merged
merged 3 commits into from
May 21, 2019

Conversation

thomaszurkan-optimizely
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely commented May 17, 2019

…of test for this.

Summary

This wraps the ephemeral session creation with a try catch and logs an error. if it fails, it returns nil which will in turn cause the session to be nil which will in turn make the NSURLSessionUploadTask nil in which case resume will be a noop and the completion handler would never be called. This should result in a failed session being a noop.

Test plan

Here is where the magic of objective-c happens. I wrote a unit test by swizzling URLSessionConfiguration to raise an exception. I then swizzle it back after the test completes.

I discovered with this test that attempting to use a background session can cause a different kind of exception. So, in order to avoid any such exception, we simply return nil and the event is not sent. It will then be sent on the next attempt to send events.

@thomaszurkan-optimizely thomaszurkan-optimizely changed the title (fix):this needs to be tested and i think we should come up with some sort … (fix):When a ephemeral session configuration causes an exception, catch try background or return nil. May 17, 2019
@coveralls
Copy link

coveralls commented May 17, 2019

Coverage Status

Coverage decreased (-0.04%) to 98.153% when pulling 8ab35f4 on patchFor302 into d0daf2e on master.

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

I'd let @jaeopt take a look at this.

Also, adding @mikeng13

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

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

Looks good so far

Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

@thomaszurkan-optimizely thomaszurkan-optimizely merged commit fd51628 into master May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants