Skip to content

Commit 383567e

Browse files
committed
Handle error when stream was cancelled prior to calling halfClose.
1 parent 51b4a1c commit 383567e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/AbstractStream.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,21 @@ private void close(State finalState, Status status) {
352352
getClass().getSimpleName(),
353353
"(%x) Closing stream client-side",
354354
System.identityHashCode(this));
355-
call.halfClose();
355+
try {
356+
call.halfClose();
357+
} catch (IllegalStateException e) {
358+
// Secondary failure encountered. The underlying RPC has entered an error state. We will
359+
// log and continue since the RPC is being discarded anyway.
360+
//
361+
// Example, "IllegalStateException: call was cancelled" was observed in
362+
// https://github.com/firebase/firebase-android-sdk/issues/6883
363+
// Likely caused by other part of system already cancelling stream.
364+
Logger.debug(
365+
getClass().getSimpleName(),
366+
"(%x) Closing stream client-side result in exception: [%s]",
367+
System.identityHashCode(this),
368+
e);
369+
}
356370
}
357371
call = null;
358372
}

0 commit comments

Comments
 (0)