Skip to content

Fix NPE when Drawable.getCurrent returns null#2545

Merged
aleksandr-gringauz merged 1 commit into
release/2.19.0from
aleksandr-gringauz/fix-npe-drawable-current-release
Mar 13, 2025
Merged

Fix NPE when Drawable.getCurrent returns null#2545
aleksandr-gringauz merged 1 commit into
release/2.19.0from
aleksandr-gringauz/fix-npe-drawable-current-release

Conversation

@aleksandr-gringauz

Copy link
Copy Markdown
Contributor

What does this PR do?

LegacyDrawableToColorMapper.mapDrawableToColor can crash with NPE when invoked on a StateListDrawable, whose getCurrent() method returns null. This can happen when <selector> doesn't contain the default item.

demo [internal]

https://mobile-integration.datadoghq.com/rum/replay/sessions/de3b1c36-f346-4733-abdf-d295f21b99e4?seed=31a96bad-0d88-4292-8e2f-9dd615cadab4&ts=1741884288920

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

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)

@aleksandr-gringauz
aleksandr-gringauz marked this pull request as ready for review March 13, 2025 17:05
@aleksandr-gringauz
aleksandr-gringauz requested review from a team as code owners March 13, 2025 17:05
@codecov-commenter

codecov-commenter commented Mar 13, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.07%. Comparing base (19edaea) to head (8caa3a4).
Report is 2 commits behind head on release/2.19.0.

Additional details and impacted files
@@                Coverage Diff                 @@
##           release/2.19.0    #2545      +/-   ##
==================================================
+ Coverage           70.03%   70.07%   +0.04%     
==================================================
  Files                 797      797              
  Lines               29994    30040      +46     
  Branches             5016     5029      +13     
==================================================
+ Hits                21005    21049      +44     
+ Misses               7598     7588      -10     
- Partials             1391     1403      +12     
Files with missing lines Coverage Δ
...sessionreplay/utils/LegacyDrawableToColorMapper.kt 49.37% <100.00%> (+0.50%) ⬆️

... and 35 files with indirect coverage changes

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

@aleksandr-gringauz
aleksandr-gringauz merged commit 3402c85 into release/2.19.0 Mar 13, 2025
@aleksandr-gringauz
aleksandr-gringauz deleted the aleksandr-gringauz/fix-npe-drawable-current-release branch March 13, 2025 18:10
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.

3 participants