Skip to content

RUM-16086: Catch errors in convertToRumViewAttributes#3497

Merged
abrooksv merged 2 commits into
developfrom
abrooks/RUM-16086
Jun 4, 2026
Merged

RUM-16086: Catch errors in convertToRumViewAttributes#3497
abrooksv merged 2 commits into
developfrom
abrooks/RUM-16086

Conversation

@abrooksv

@abrooksv abrooksv commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

When deserializing the Parcel inside the Bundle, the methods get/keySet may throw LinkageErrors from Class.forName or BadParcelableException when other errors happen. In those situations, return an empty map for the view attributes.

API versions before 33 threw from keySet() due to the eager deserialization, but after that version, get throws due to switching to lazy deserialization so we must wrap both method calls.

Motivation

Code can throw if the Parcel data is invalid:

java.lang.NoClassDefFoundError: Invalid descriptor: .
	at java.lang.Class.classForName(Native Method:0)
	at java.lang.Class.forName(Class.java:453)
	at android.os.Parcel$2.resolveClass(Parcel.java:2920)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1615)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1520)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1776)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
	at android.os.Parcel.readSerializable(Parcel.java:2928)
	at android.os.Parcel.readValue(Parcel.java:2720)
	at android.os.Parcel.readArrayMapInternal(Parcel.java:3038)
	at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
	at android.os.BaseBundle.unparcel(BaseBundle.java:232)
	at android.os.BaseBundle.keySet(BaseBundle.java:557)
	at com.datadog.android.rum.tracking.BundleExtKt.convertToRumViewAttributes(BundleExt.kt:21)

Additional Notes

For testing, I am using Mockito to inject the behavior due to in our version of roboeletric, the Parcel serialization/deserialization uses an Android specific java.util.Array.checkOffsetAndCount(int, int, int) leading to NoSuchMethodErrors

I attempted to upgrade it to API version 35 (36 requires JDK 21, and we still run 17 in CI), but that change got too big for this PR so I stopped. LMK if there is any interest in that and I can take another look into finishing the upgrade as another set of PRs

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

When deserializing the Parcel inside the Bundle, the methods get/keySet may throw LinkageErrors from Class.forName or BadParcelableException when other errors happen. In those situations, return an empty map for the view attributes.
@abrooksv
abrooksv force-pushed the abrooks/RUM-16086 branch from 49f4733 to 73b9ece Compare June 2, 2026 23:14
@abrooksv
abrooksv marked this pull request as ready for review June 2, 2026 23:30
@abrooksv
abrooksv requested review from a team as code owners June 2, 2026 23:30
@codecov-commenter

codecov-commenter commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.21%. Comparing base (91882c1) to head (640344c).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3497      +/-   ##
===========================================
- Coverage    72.23%   72.21%   -0.02%     
===========================================
  Files          965      965              
  Lines        35595    35600       +5     
  Branches      5932     5932              
===========================================
- Hits         25712    25708       -4     
- Misses        8274     8287      +13     
+ Partials      1609     1605       -4     
Files with missing lines Coverage Δ
...tlin/com/datadog/android/rum/tracking/BundleExt.kt 100.00% <100.00%> (ø)

... and 33 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

0xnm
0xnm previously approved these changes Jun 3, 2026
jonathanmos
jonathanmos previously approved these changes Jun 3, 2026
ambushwork
ambushwork previously approved these changes Jun 3, 2026
Co-authored-by: Jonathan Moskovich <[email protected]>
@abrooksv
abrooksv dismissed stale reviews from ambushwork, jonathanmos, and 0xnm via 640344c June 3, 2026 13:59
@datadog-official

This comment has been minimized.

@abrooksv
abrooksv requested review from ambushwork and jonathanmos and removed request for ambushwork June 3, 2026 17:02
@abrooksv
abrooksv merged commit 6c72554 into develop Jun 4, 2026
27 checks passed
@abrooksv
abrooksv deleted the abrooks/RUM-16086 branch June 4, 2026 14:01
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