You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue appears to have been introduced after #588, where persisted DomainMapping parsing began expecting overridesSubdirectory to always be present.
Users upgrading from older Android SDK versions can still have persisted UploadSettings / NetworkOptions JSON containing legacy domainMappings entries that do not include overridesSubdirectory.
In mParticle logs, this surfaced as:
No value for overridesSubdirectory
Attempt to invoke virtual method 'com.mparticle.networking.DomainMapping com.mparticle.networking.DomainMapping$Builder.build()' on a null object reference
The current parser expected overridesSubdirectory to always be present, which caused legacy entries to fail parsing.
In the persisted NetworkOptions flow, that parse failure could produce a null DomainMapping.Builder, and the subsequent .build() call could trigger a null object reference crash.
Because these values are read from persisted upload settings, affected users could continue seeing repeated failures until the stale rows were replaced.
What Has Changed
Updated DomainMapping JSON parsing to use a backward-compatible default of false when overridesSubdirectory is missing.
Hardened NetworkOptions parsing so invalid persisted domain mapping entries are skipped instead of crashing the entire parse flow.
Added regression tests covering:
legacy persisted DomainMapping JSON without overridesSubdirectory
NetworkOptions JSON with one valid persisted mapping and one invalid mapping
Screenshots/Video
Not applicable for this change.
Checklist
I have performed a self-review of my own code.
I have made corresponding changes to the documentation.
I have added tests that prove my fix is effective or that my feature works.
Medium Risk
Touches persisted NetworkOptions/DomainMapping JSON parsing used to route network traffic, so a bug could change endpoint selection or pinning behavior; changes are small and add safe defaults/guards to reduce crash risk.
Overview
Improves resilience when deserializing persisted NetworkOptions containing legacy or corrupted domainMappings.
DomainMapping now treats missing overridesSubdirectory as false via optBoolean, and NetworkOptions.withNetworkOptions skips (with a warning) any domain mapping entries that fail to parse instead of calling .build() on a null builder.
Adds unit tests covering legacy mappings without overridesSubdirectory and mixed valid/invalid persisted mappings.
Reviewed by Cursor Bugbot for commit a99c2dc. Bugbot is set up for automated code reviews on this repo. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Background
DomainMappingparsing began expectingoverridesSubdirectoryto always be present.UploadSettings/NetworkOptionsJSON containing legacydomainMappingsentries that do not includeoverridesSubdirectory.No value for overridesSubdirectoryAttempt to invoke virtual method 'com.mparticle.networking.DomainMapping com.mparticle.networking.DomainMapping$Builder.build()' on a null object referenceoverridesSubdirectoryto always be present, which caused legacy entries to fail parsing.NetworkOptionsflow, that parse failure could produce a nullDomainMapping.Builder, and the subsequent.build()call could trigger a null object reference crash.What Has Changed
DomainMappingJSON parsing to use a backward-compatible default offalsewhenoverridesSubdirectoryis missing.NetworkOptionsparsing so invalid persisted domain mapping entries are skipped instead of crashing the entire parse flow.DomainMappingJSON withoutoverridesSubdirectoryNetworkOptionsJSON with one valid persisted mapping and one invalid mappingScreenshots/Video
Checklist
Additional Notes
./gradlew :android-core:testDebugUnitTest --tests com.mparticle.networking.NetworkOptionsTest