Skip to content

Commit b8ce2b1

Browse files
committed
resolve comments
1 parent 09c50bb commit b8ce2b1

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

firebase-firestore/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
2-
- [fixed] Fix FAILED_PRECONDITION when writing to a deleted document in a transaction. Ported from web SDK.
3-
See the [issue report in GitHub](https://github.com/firebase/firebase-js-sdk/issues/5871).
2+
- [fixed] Fix FAILED_PRECONDITION when writing to a deleted document in a transaction.
3+
(#5871).
4+
45
- [fixed] Fixed Firestore failing to raise initial snapshot from empty local cache result.
56

67
# 24.4.0

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/TransactionTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ private enum FromDocumentType {
8282
* Used for testing that all possible combinations of executing transactions result in the desired
8383
* document value or error.
8484
*
85-
* <p>`run()`, `withExistingDoc()`,`withNonexistentDoc()` and `withDeletedDoc()` don't actually do
86-
* anything except assign variables into the TransactionTester.
85+
* <p>`run()`, `withExistingDoc()`, `withNonexistentDoc()` and `withDeletedDoc()` don't actually
86+
* do anything except assign variables into the TransactionTester.
8787
*
8888
* <p>`expectDoc()`, `expectNoDoc()`, and `expectError()` will trigger the transaction to run and
8989
* assert that the end result matches the input.
@@ -188,7 +188,7 @@ private void prepareDoc() {
188188
waitFor(docRef.delete());
189189
break;
190190
default:
191-
throw new Error("invalid fromDocumentType: " + fromDocumentType);
191+
throw new RuntimeException("invalid fromDocumentType: " + fromDocumentType);
192192
}
193193
}
194194

@@ -709,23 +709,23 @@ public void testDoesNotRetryOnPermanentError() {
709709
public void testRetryOnAlreadyExistsError() {
710710
final FirebaseFirestore firestore = testFirestore();
711711
DocumentReference doc = firestore.collection("foo").document();
712-
CountDownLatch latch = new CountDownLatch(2);
712+
AtomicInteger retryCount = new AtomicInteger(0);
713713
waitFor(
714714
firestore.runTransaction(
715715
transaction -> {
716-
latch.countDown();
716+
retryCount.getAndIncrement();
717717
transaction.get(doc);
718718
// Do a write outside of the transaction.
719-
waitFor(doc.set(map("count", 1)));
720-
// Now try to set the doc within the transaction.This should fail once
719+
if (retryCount.get() == 1) waitFor(doc.set(map("count", retryCount.get())));
720+
// Now try to set the doc within the transaction. This should fail once
721721
// with ALREADY_EXISTS error.
722-
transaction.set(doc, map("count", 2));
722+
transaction.set(doc, map("count", 22));
723723
return null;
724724
}));
725725
DocumentSnapshot snapshot = waitFor(doc.get());
726-
assertEquals(0, latch.getCount());
726+
assertEquals(2, retryCount.get());
727727
assertTrue(snapshot.exists());
728-
assertEquals(2L, snapshot.getData().get("count"));
728+
assertEquals(22L, snapshot.getData().get("count"));
729729
}
730730

731731
@Test

0 commit comments

Comments
 (0)