Skip to content

Commit fda3351

Browse files
authored
Handle error when stream was cancelled prior to calling halfClose. (#6894)
This should fix issue #6883
1 parent fd65539 commit fda3351

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

firebase-firestore/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22
* [fixed] Fixed the `null` value handling in `whereNotEqualTo` and `whereNotIn` filters.
3+
* [fixed] Catch exception when stream is already cancelled during close. [#6894](//github.com/firebase/firebase-android-sdk/pull/6894)
34

45
# 25.1.3
56
* [fixed] Use lazy encoding in UTF-8 encoded byte comparison for strings to solve performance issues. [#6706](//github.com/firebase/firebase-android-sdk/pull/6706)

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

+15-1
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)