[PR #4227] [CLOSED] PM-14433 update flow type to nullable so we can handle when an empty … #4787

Closed
opened 2025-11-26 23:49:45 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/4227
Author: @dseverns-livefront
Created: 11/4/2024
Status: Closed

Base: mainHead: PM-14433-crash-retrieving-domains


📝 Commits (1)

  • 44eff52 PM-14433 update flow type to nullable so we can handle when an empty table is queried

📊 Changes

2 files changed (+3 additions, -1 deletions)

View changed files

📝 app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/disk/VaultDiskSourceImpl.kt (+2 -0)
📝 app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/DomainsDao.kt (+1 -1)

📄 Description

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14433

📔 Objective

  • Avoid call on a null object when a query is made against an empty table returning a Flow.
  • According to the documentation, this should have thrown a NPE, but it seems that there is an open issue where it actually is returning Flow<T?> and emitting null. Updating the contract to return a Flow<DomainEntity> so it matches the result we get from Room, then we filter out the null emissions where we are mapping back to the JSON.
  • FWIW: I checked other areas in the codebase where we are returning Flows from Room and they are all Flow<List<T>> so they will return an empty list when the table is empty.

Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/4227 **Author:** [@dseverns-livefront](https://github.com/dseverns-livefront) **Created:** 11/4/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `PM-14433-crash-retrieving-domains` --- ### 📝 Commits (1) - [`44eff52`](https://github.com/bitwarden/android/commit/44eff52ff6d849d7dd8557ed41a0719a44218342) PM-14433 update flow type to nullable so we can handle when an empty table is queried ### 📊 Changes **2 files changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/disk/VaultDiskSourceImpl.kt` (+2 -0) 📝 `app/src/main/java/com/x8bit/bitwarden/data/vault/datasource/disk/dao/DomainsDao.kt` (+1 -1) </details> ### 📄 Description ## 🎟️ Tracking https://bitwarden.atlassian.net/browse/PM-14433 <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective - Avoid call on a null object when a query is made against an empty table returning a Flow. - According to the [documentation](https://developer.android.com/reference/androidx/room/Query), this should have thrown a NPE, but it seems that there is an open [issue](https://issuetracker.google.com/issues/213175894) where it actually is returning Flow<T?> and emitting `null`. Updating the contract to return a `Flow<DomainEntity>` so it matches the result we get from Room, then we filter out the null emissions where we are mapping back to the JSON. - FWIW: I checked other areas in the codebase where we are returning `Flow`s from Room and they are all `Flow<List<T>>` so they will return an empty list when the table is empty. <!-- Describe what the purpose of this PR is, for example what bug you're fixing or new feature you're adding. --> ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:49:45 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#4787