-
Notifications
You must be signed in to change notification settings - Fork 648
Closed
Description
[REQUIRED] Step 2: Describe your environment
- Android Studio version: Android Studio Electric Eel | 2022.1.1 Patch 1
- Firebase Component: Firestore
- Component version: 24.4.0, 24.4.3
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
- Disconnect from the Internet.
- Launch my app.
- Write a Document containing a field having
@ServerTimestampannotation by “Set” operation with “merge” option. - Repeat step 3 many times (some hundreds).
SQLiteDocumentOverlayCache#saveOverlayordecodeOverlaythrowsStackOverflowErrorwhile serializing/deserializing nested "ServerTimestamp" (MapValue) objects.
Relevant Code:
IMHO, no need to keep nested previous value of "ServerTimestamp" object. And, just the oldest value is needed.
So, below patch resolves "deeply nested ServerTimestamp". But, saved overlay causes StackOverflow when it is parsed.
diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/model/ServerTimestamps.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/model/ServerTimestamps.java
index 7ae19eadc..ef7b547fd 100644
--- a/firebase-firestore/src/main/java/com/google/firebase/firestore/model/ServerTimestamps.java
+++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/model/ServerTimestamps.java
@@ -62,8 +62,9 @@ public final class ServerTimestamps {
.putFields(TYPE_KEY, encodedType)
.putFields(LOCAL_WRITE_TIME_KEY, encodeWriteTime);
- if (previousValue != null) {
- mapRepresentation.putFields(PREVIOUS_VALUE_KEY, previousValue);
+ Value actualPreviousValue = previousValue == null ? null : getPreviousValue(previousValue);
+ if (actualPreviousValue != null) {
+ mapRepresentation.putFields(PREVIOUS_VALUE_KEY, actualPreviousValue);
}
return Value.newBuilder().setMapValue(mapRepresentation).build();minsoojun-cloud