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

FIX [#642, RUM-3855]: Android Runtime Error in v2.3.1 for ReadableArray.asFirstPartyHosts() #644

Merged

Conversation

marco-saia-datadog
Copy link
Member

@marco-saia-datadog marco-saia-datadog commented Mar 28, 2024

What does this PR do?

ISSUE: #642

INTRODUCED WITH: v2.3.0 in PR #625

Fixes a wrong cast which leads to a Runtime Error.

Details

The tests rely on JavaOnlyMap, but its method toHashMap just wraps the map using a HashMap, without converting nested maps and arrays.

The ReadableNativeMap, which is the one used in a real use case, has a different implementation of toHashMap , which recursively converts the nested objects in either stdlib HashMap(s) or ArrayList(s).

The error shows up because .asFirstPartyHosts() performs an unsafe cast to ReadableMap for the nested objects inside of the array, but the actual type is HashMap from kotlin stdlib.

This PR introduces new conversion functions to ensure that the logic is consistent for different implementations of ReadableArray and ReadableMap.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • 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)

@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/fix/issue-642-hashmap-to-readablemap branch 2 times, most recently from 6a8e09c to 83d323c Compare March 28, 2024 13:40
@marco-saia-datadog marco-saia-datadog marked this pull request as ready for review March 28, 2024 15:32
@marco-saia-datadog marco-saia-datadog requested a review from a team as a code owner March 28, 2024 15:32
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/fix/issue-642-hashmap-to-readablemap branch from f6ae714 to 800e4c7 Compare April 3, 2024 13:06
@marco-saia-datadog marco-saia-datadog requested a review from 0xnm April 3, 2024 13:06
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/fix/issue-642-hashmap-to-readablemap branch 2 times, most recently from 0db299c to c955537 Compare April 4, 2024 10:34
@marco-saia-datadog marco-saia-datadog requested a review from 0xnm April 4, 2024 10:34
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/fix/issue-642-hashmap-to-readablemap branch from c955537 to dc35cfa Compare April 4, 2024 10:40
0xnm
0xnm previously approved these changes Apr 4, 2024
Copy link
Member

@0xnm 0xnm left a comment

Choose a reason for hiding this comment

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

lgtm! I hope that we add also integration test to check full configuration conversion through the layers.

@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/fix/issue-642-hashmap-to-readablemap branch from dc35cfa to 80bd61a Compare April 4, 2024 11:43
@marco-saia-datadog marco-saia-datadog requested a review from 0xnm April 4, 2024 11:45
@marco-saia-datadog marco-saia-datadog force-pushed the marcosaia/fix/issue-642-hashmap-to-readablemap branch from 80bd61a to ebd6552 Compare April 4, 2024 12:06
@marco-saia-datadog marco-saia-datadog merged commit 52be8fb into develop Apr 4, 2024
6 checks passed
@marco-saia-datadog marco-saia-datadog deleted the marcosaia/fix/issue-642-hashmap-to-readablemap branch April 4, 2024 12:26
@marco-saia-datadog marco-saia-datadog changed the title FIX #642: Android Runtime Error in v2.3.1 for ReadableArray.asFirstPartyHosts() FIX [#642, RUM-3857]: Android Runtime Error in v2.3.1 for ReadableArray.asFirstPartyHosts() Apr 4, 2024
@marco-saia-datadog marco-saia-datadog changed the title FIX [#642, RUM-3857]: Android Runtime Error in v2.3.1 for ReadableArray.asFirstPartyHosts() FIX [#642, RUM-3855]: Android Runtime Error in v2.3.1 for ReadableArray.asFirstPartyHosts() Apr 4, 2024
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