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 =