Skip to content

Commit fcf959d

Browse files
authored
Added blocking with Firebase sample to prevent race conditions during tests. (GoogleCloudPlatform#925)
1 parent 2042a94 commit fcf959d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

firestore/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ public Void updateCallback(Transaction transaction) throws Exception {
345345
String returnInfoFromTransaction(long population) throws Exception {
346346
Map<String, Object> map = new HashMap<>();
347347
map.put("population", population);
348-
db.collection("cities").document("SF").set(map);
348+
// Block until transaction is complete is using transaction.get()
349+
db.collection("cities").document("SF").set(map).get();
349350
// [START fs_return_info_transaction]
350351
final DocumentReference docRef = db.collection("cities").document("SF");
351352
ApiFuture<String> transaction =

0 commit comments

Comments
 (0)