Skip to content

Closing Firestore instance on FirebaseApp.delete() - #227

Merged
hiranya911 merged 4 commits into
masterfrom
hkj-firestore-close
Nov 30, 2018
Merged

hiranya911 merged 4 commits into
masterfrom
hkj-firestore-close

Conversation

@hiranya911

Copy link
Copy Markdown
Contributor

Ensures proper clean up of Firestore instance. Helps avoid warnings such as the following during tests:

Nov 28, 2018 4:46:23 PM io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference cleanQueue
SEVERE: *~*~*~ Channel ManagedChannelImpl{logId=1, target=firestore.googleapis.com:443} was not shutdown properly!!! ~*~*~*
    Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
java.lang.RuntimeException: ManagedChannel allocation site
	at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:103)

@mikelehen mikelehen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is the behavior of Firestore objects after close() is called? Like if I delete the app, but another part of my code still has DocumentReference objects and tries to set() / get() them, do I get a sane error?

@mikelehen mikelehen assigned hiranya911 and unassigned mikelehen Nov 29, 2018
@hiranya911

Copy link
Copy Markdown
Contributor Author

It does indeed:

java.lang.IllegalStateException: Firestore client has already been closed
	at com.google.common.base.Preconditions.checkState(Preconditions.java:444)
	at com.google.cloud.firestore.FirestoreImpl.streamRequest(FirestoreImpl.java:429)
	at com.google.cloud.firestore.FirestoreImpl.getAll(FirestoreImpl.java:250)
	at com.google.cloud.firestore.FirestoreImpl.getAll(FirestoreImpl.java:160)
	at com.google.cloud.firestore.DocumentReference.get(DocumentReference.java:352)

I have updated the docs and tests to reflect this.

@mikelehen mikelehen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants