From fcf959d7c2a7f4c86ac88ff1c1e1008085e26e91 Mon Sep 17 00:00:00 2001 From: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> Date: Tue, 21 Nov 2017 08:05:23 -0800 Subject: [PATCH] Added blocking with Firebase sample to prevent race conditions during tests. (#925) --- .../com/example/firestore/snippets/ManageDataSnippets.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firestore/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java b/firestore/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java index 30427e705c9..a2493d7352a 100644 --- a/firestore/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java +++ b/firestore/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java @@ -345,7 +345,8 @@ public Void updateCallback(Transaction transaction) throws Exception { String returnInfoFromTransaction(long population) throws Exception { Map map = new HashMap<>(); map.put("population", population); - db.collection("cities").document("SF").set(map); + // Block until transaction is complete is using transaction.get() + db.collection("cities").document("SF").set(map).get(); // [START fs_return_info_transaction] final DocumentReference docRef = db.collection("cities").document("SF"); ApiFuture transaction =