Fix leak in ChatService.disconnectChatSession. #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
**Issue Number: - **
Description:
ChatService.disconnectChatSession is leaking resources because it is not calling completion block on all its paths. Because of that its clients will hang forever waiting for completion block to be called. This will further lead to leaked tasks (or continuations if SDK users wrap callback APIs into async-await continuations) in the application that uses amazon-connect-chat-ios SDK.
This fix ads call to completion block at the place where it was missing. Assumption is that if chat session is not active, and we call disconnect, we should consider this as successful disconnection.
Functional backward compatibility:
Does this change introduce backwards incompatible changes? NO
Does this change introduce any new dependency? NO
Testing:
Is the code unit tested?
No.
Have you tested the changes with a sample UI (e.g. iOS Mobile Chat Example)?
No, we detected the leaks/crashes in our application and tracked the root cause. The bug is obvious by just looking at the ChatService.disconnectChatSession code, so there is no point in trying to test it on sample UI.