Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,11 @@ public static void main(String[] args) throws Exception {
String projectId = (args.length == 0) ? null : args[0];
Quickstart quickStart = (projectId != null) ? new Quickstart(projectId) : new Quickstart();
quickStart.run();
quickStart.close();
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,8 @@ public void onEvent(@Nullable QuerySnapshot snapshots,
// [END listen_errors]
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,8 @@ public void updateDocumentIncrement() throws ExecutionException, InterruptedExce
updateFuture.get();
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,9 @@ Query filterNotIn() {
// [END fs_filter_not_in]
return query;
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be overridden? It seems like the method in BaseIntegrationTest does the right thing already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,because QueryDataSnippets class also have instance variable with name db of type Firestore means BaseIntegrationTest have different instance while QueryDataSnippets class have a different instance of Firestore.

db.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,9 @@ public Iterable<CollectionReference> listCollections() throws Exception {
// [END fs_get_collections]
return collections;
}

/** Closes the gRPC channels associated with this instance and frees up their resources. */
void close() throws Exception {
db.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.cloud.firestore.FirestoreOptions;
import com.google.cloud.firestore.QuerySnapshot;
import java.util.Map;
import org.junit.AfterClass;
import org.junit.BeforeClass;

/**
Expand Down Expand Up @@ -83,4 +84,8 @@ protected static void deleteAllDocuments(Firestore db) throws Exception {
}
}

@AfterClass
public static void tearDownAfterClass() throws Exception {
db.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@ private void deleteAllDocuments() throws Exception {
@After
public void tearDown() throws Exception {
deleteAllDocuments();
quickstart.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@ public void testListenForChanges() throws Exception {
@AfterClass
public static void tearDown() throws Exception {
deleteAllDocuments(db);
listenDataSnippets.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,6 @@ public void testUpdateDocumentIncrementSuccessful() throws Exception {
public static void tearDown() throws Exception {
manageDataSnippets.deleteCollection(db.collection("cities"), 10);
manageDataSnippets.deleteCollection(db.collection("users"), 10);
manageDataSnippets.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,6 @@ private List<String> getResults(Query query) throws Exception {
@AfterClass
public static void tearDown() throws Exception {
deleteAllDocuments(db);
queryDataSnippets.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ private static void deleteAllDocuments() throws Exception {
@AfterClass
public static void tearDownAfterClass() throws Exception {
deleteAllDocuments();
retrieveDataSnippets.close();
}
}