Skip to content

Commit

Permalink
Fix issues with CustomerSession listeners (#856)
Browse files Browse the repository at this point in the history
* Fix issues with CustomerSession listeners

**Motivation**
The previous implementation of `CustomerSession` listeners
had a reference to a single `CustomerRetrievalListener` and
`SourceRetrievalListener`. After a listener is called, it
would be nulled out.

This logic was buggy because it resulted in possible race
conditions in which two calls are both in flight, and the
first call that completes nulls out the listener for the
second.

**Summary**
The solution to this issue is to associate an `operationId`
(i.e. UUID) with each listener. This avoids the race condition
and ambiguity about which listener is being referenced.

Additionally, the listeners were being held with a strong
reference, which could lead to memory leaks if the listener
held a reference to an Activity.

**Testing**
Manually verified with samplestore and example apps.
  • Loading branch information
mshafrir-stripe committed Apr 9, 2019
1 parent b5f5f00 commit 2c44949
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ String getType() {
return mType;
}

@Nullable
@NonNull
protected static <TEphemeralKey extends AbstractEphemeralKey> TEphemeralKey
fromString(@Nullable String rawJson, Class ephemeralKeyClass) throws JSONException {
if (rawJson == null) {
Expand Down

0 comments on commit 2c44949

Please sign in to comment.