Skip to content

Change DocumentOverlayCache.saveOverlays() to require non-null values in the given Map #3518

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

Merged
merged 17 commits into from
Mar 18, 2022

Conversation

dconeybe
Copy link
Contributor

The current implementations of DocumentOverlayCache.saveOverlays() checks that each value in the given Map is non-null, and if it is null it ignores it, as if the key/value pair wasn't even present in the map.

This PR changes the logic to assume that none of the values in the Map are null and modifies the call sites to ensure that they avoid putting null values into the map.

This is a slightly cleaner implementation and makes the null behavior more explicit at the call site.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 10, 2022

Coverage Report 1

Affected Products

  • firebase-firestore

    Overall coverage changed from 45.65% (ea5490c) to 45.66% (59cf167) by +0.01%.

    FilenameBase (ea5490c)Merge (59cf167)Diff
    MutationBatch.java89.23%89.39%+0.16%
    Preconditions.java43.75%52.63%+8.88%
    SQLiteDocumentOverlayCache.java97.83%97.85%+0.02%

Test Logs

Notes

  • Commit (59cf167) is created by Prow via merging PR base commit (ea5490c) and head commit (41c620e).
  • Run gradle <product>:checkCoverage to produce HTML coverage reports locally. After gradle commands finished, report files can be found under <product-build-dir>/reports/jacoco/.

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/OCJvhDoZVy.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 10, 2022

Size Report 1

Affected Products

  • firebase-firestore

    TypeBase (ea5490c)Merge (59cf167)Diff
    aar1.24 MB1.24 MB+327 B (+0.0%)
    apk (release)3.38 MB3.38 MB+184 B (+0.0%)

Test Logs

Notes

  • Commit (59cf167) is created by Prow via merging PR base commit (ea5490c) and head commit (41c620e).

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/yGAAcerEmk.html

dconeybe added a commit to firebase/firebase-js-sdk that referenced this pull request Mar 10, 2022
if (mutation == null) {
return;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

we should assert mutation != null, since mutation.getKey() is being used below.

Copy link
Contributor

Choose a reason for hiding this comment

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

or does removing the @Nullable achieve the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an explicit null check in saveOverlays(). @nullable is just a compile-time check and doesn't affect runtime behavior. I also added a unit test.

@dconeybe dconeybe merged commit ea8957d into master Mar 18, 2022
@dconeybe dconeybe deleted the dconeybe/OverlayNeverNull branch March 18, 2022 14:29
jeremyjiang-dev pushed a commit that referenced this pull request Mar 24, 2022
jeremyjiang-dev pushed a commit that referenced this pull request Mar 25, 2022
jeremyjiang-dev pushed a commit that referenced this pull request Mar 25, 2022
jeremyjiang-dev pushed a commit that referenced this pull request Mar 25, 2022
ehsannas added a commit to firebase/firebase-js-sdk that referenced this pull request Apr 6, 2022
* Integrate Document Overlay with the SDK.

* we should call ObjectValue.delete if value is null.

* Remove unnecessary null check from MemoryDocumentOverlayCache.saveOverlay(), like is done in firebase/firebase-android-sdk#3518

* Address comments.

* Port changes from Android SDK PR#3420.

Note that we are not going to do any processing in the background.

* Port overlay recalculation bug (Android SDK PR #3495).

* Fix overlay bug when offline (Port Android SDK PR #3537).

* Address feedback.

* Better null check.

Co-authored-by: Denver Coneybeare <[email protected]>
@firebase firebase locked and limited conversation to collaborators Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants