Skip to content

RUM-7740: Extract drawable key generation from ResourcesLRUCache#3279

Merged
hamorillo merged 2 commits into
developfrom
hector.morilloprieto/RUM-7740
Mar 23, 2026
Merged

RUM-7740: Extract drawable key generation from ResourcesLRUCache#3279
hamorillo merged 2 commits into
developfrom
hector.morilloprieto/RUM-7740

Conversation

@hamorillo

Copy link
Copy Markdown
Contributor

What does this PR do?

Removes the unsafe as? ResourcesLRUCache downcast in
BitmapCachesManager.generateResourceKeyFromDrawable by extracting key
generation into a dedicated DrawableKeyGenerator interface with a
ResourceDrawableKeyGenerator implementation. BitmapCachesManager now
accepts a DrawableKeyGenerator as an injected dependency, eliminating
the need to know about the concrete cache type.

Motivation

The original code performed a silent safe-cast to ResourcesLRUCache
inside BitmapCachesManager, meaning any non-ResourcesLRUCache
implementation of Cache<String, ByteArray> would silently return null
from generateResourceKeyFromDrawable. The new design separates storage
from key generation and makes the dependency explicit and mockable in tests.

Additional Notes

No public API surface changes.

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)

… a dedicated class

Removes the unsafe `as? ResourcesLRUCache` downcast in
`BitmapCachesManager.generateResourceKeyFromDrawable` by separating
key generation into its own abstraction.

Introduces `DrawableKeyGenerator` interface and
`ResourceDrawableKeyGenerator` implementation, which now holds all
the prefix/hash logic previously embedded in `ResourcesLRUCache`.
`BitmapCachesManager` accepts a `DrawableKeyGenerator` as an injected
dependency, eliminating the need to know about the concrete cache type.
@hamorillo hamorillo changed the title RUM-7740: Extract drawable key generation from ResourcesLRUCache into a dedicated class RUM-7740: Extract drawable key generation from ResourcesLRUCache Mar 23, 2026
@datadog-datadog-prod-us1-2

This comment has been minimized.

@hamorillo

Copy link
Copy Markdown
Contributor Author

@codex review

@codecov-commenter

codecov-commenter commented Mar 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.53%. Comparing base (61409f2) to head (99df6a0).
⚠️ Report is 72 commits behind head on develop.

Files with missing lines Patch % Lines
...recorder/resources/ResourceDrawableKeyGenerator.kt 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3279      +/-   ##
===========================================
- Coverage    71.68%   71.53%   -0.15%     
===========================================
  Files          942      943       +1     
  Lines        34811    34814       +3     
  Branches      5899     5898       -1     
===========================================
- Hits         24954    24903      -51     
- Misses        8233     8274      +41     
- Partials      1624     1637      +13     
Files with missing lines Coverage Δ
...nreplay/internal/recorder/SessionReplayRecorder.kt 95.56% <100.00%> (+0.03%) ⬆️
...internal/recorder/resources/BitmapCachesManager.kt 100.00% <100.00%> (+4.35%) ⬆️
...y/internal/recorder/resources/ResourcesLRUCache.kt 54.55% <ø> (-13.02%) ⬇️
...recorder/resources/ResourceDrawableKeyGenerator.kt 87.50% <87.50%> (ø)

... and 30 files with indirect coverage changes

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@hamorillo
hamorillo marked this pull request as ready for review March 23, 2026 10:52
@hamorillo
hamorillo requested review from a team as code owners March 23, 2026 10:52
0xnm
0xnm previously approved these changes Mar 23, 2026
ambushwork
ambushwork previously approved these changes Mar 23, 2026
@hamorillo
hamorillo dismissed stale reviews from ambushwork and 0xnm via 99df6a0 March 23, 2026 13:41
@hamorillo
hamorillo requested review from 0xnm and ambushwork March 23, 2026 13:42
@hamorillo
hamorillo merged commit b3abae6 into develop Mar 23, 2026
26 checks passed
@hamorillo
hamorillo deleted the hector.morilloprieto/RUM-7740 branch March 23, 2026 15:40
@ncreated
ncreated restored the hector.morilloprieto/RUM-7740 branch April 9, 2026 09:50
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.

4 participants