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

Set pending shared state before updating Identity Map #81

Merged
merged 2 commits into from
Jan 12, 2023

Conversation

kevinlind
Copy link
Collaborator

Set a pending shared state before update and remove Identity Map operations.

Description

A race condition can occur when updating the IdentityMap followed by an Edge.sendEvent() call. The issue is the Identity extension doesn't finish processing the update to the IdentityMap before the Edge extension retrieves the Identity shared state. This causes the Edge Network request to use the IdentityMap before the update.

The fix is to simply create a pending shared state before any updates to the Identity Map in IdentityProperties. After the Identity Map is edited, the pending shared state is resolved with the new Identity Map XDM.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Merging #81 (6952e75) into dev-v2.0.0 (be93222) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@              Coverage Diff               @@
##           dev-v2.0.0      #81      +/-   ##
==============================================
+ Coverage       93.32%   93.39%   +0.07%     
==============================================
  Files              12       12              
  Lines             674      681       +7     
  Branches          103      103              
==============================================
+ Hits              629      636       +7     
  Misses             16       16              
  Partials           29       29              
Flag Coverage Δ
functional-tests 67.11% <60.00%> (-1.14%) ⬇️
unit-tests 93.10% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...keting/mobile/edge/identity/IdentityExtension.java 99.19% <100.00%> (+0.05%) ⬆️

@@ -268,8 +269,10 @@ void handleUpdateIdentities(@NonNull final Event event) {
return;
}

// Add pending shared state to avoid race condition between updating and reading identity map
final SharedStateResolver resolver = getApi().createPendingXDMSharedState(event);
Copy link
Contributor

Choose a reason for hiding this comment

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

would this be fast enough or can we move this before the checks and conversions above as we do in iOS?

@@ -265,11 +270,12 @@ void handleUpdateIdentities(@NonNull final Event event) {
LOG_SOURCE,
"Failed to update identifiers as no identifiers were found in the event data."
);
resolver.resolve(state.getIdentityProperties().toXDMData(false));
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to your change, but looks like toXDMData(allowEmpty) is called with false in all cases, can we remove that param? 😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The iOS code sets the value to true when handling identity and get identifiers requests, so I'll leave this as is for now and update if needed when I work on syncing the iOS and Android implementations.

@kevinlind kevinlind merged commit 796f81b into adobe:dev-v2.0.0 Jan 12, 2023
@kevinlind kevinlind deleted the mob-16020 branch January 12, 2023 17:37
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.

2 participants