37
37
import com .google .firebase .firestore .util .Util ;
38
38
import com .google .protobuf .ByteString ;
39
39
import io .grpc .Status ;
40
- import io .grpc .Status .Code ;
41
40
import java .util .ArrayDeque ;
42
41
import java .util .Deque ;
43
42
import java .util .HashMap ;
@@ -642,9 +641,10 @@ private void handleWriteStreamClose(Status status) {
642
641
643
642
private void handleWriteHandshakeError (Status status ) {
644
643
hardAssert (!status .isOk (), "Handling write error with status OK." );
645
- // Reset the token if it's a permanent error or the error code is ABORTED, signaling the write
646
- // stream is no longer valid.
647
- if (Datastore .isPermanentWriteError (status ) || status .getCode ().equals (Code .ABORTED )) {
644
+ // Reset the token if it's a permanent error, signaling the write stream is no longer valid.
645
+ // Note that the handshake does not count as a write: see comments on isPermanentWriteError for
646
+ // details.
647
+ if (Datastore .isPermanentError (status )) {
648
648
String token = Util .toDebugString (writeStream .getLastStreamToken ());
649
649
Logger .debug (
650
650
LOG_TAG ,
@@ -658,7 +658,7 @@ private void handleWriteHandshakeError(Status status) {
658
658
659
659
private void handleWriteError (Status status ) {
660
660
hardAssert (!status .isOk (), "Handling write error with status OK." );
661
- // Only handle permanent error, if it's transient just let the retry logic kick in.
661
+ // Only handle permanent errors here. If it's transient, just let the retry logic kick in.
662
662
if (Datastore .isPermanentWriteError (status )) {
663
663
// If this was a permanent error, the request itself was the problem so it's not going
664
664
// to succeed if we resend it.
0 commit comments