File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
google-cloud-firestore/src
main/java/com/google/cloud/firestore
test/java/com/google/cloud/firestore Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -570,6 +570,9 @@ private static Status getStatus(Throwable throwable) {
570570 return ((StatusRuntimeException ) throwable ).getStatus ();
571571 } else if (throwable instanceof StatusException ) {
572572 return ((StatusException ) throwable ).getStatus ();
573+ } else if (throwable instanceof ApiException
574+ && ((ApiException ) throwable ).getStatusCode ().getTransportCode () instanceof Code ) {
575+ return ((Code ) ((ApiException ) throwable ).getStatusCode ().getTransportCode ()).toStatus ();
573576 }
574577 return null ;
575578 }
Original file line number Diff line number Diff line change 3232import static org .mockito .Mockito .doAnswer ;
3333import static org .mockito .Mockito .doReturn ;
3434
35+ import com .google .api .gax .grpc .GrpcStatusCode ;
3536import com .google .api .gax .rpc .BidiStreamObserver ;
3637import com .google .api .gax .rpc .BidiStreamingCallable ;
3738import com .google .api .gax .rpc .ClientStream ;
39+ import com .google .api .gax .rpc .InternalException ;
3840import com .google .cloud .firestore .Query .Direction ;
3941import com .google .cloud .firestore .WatchTest .SnapshotDocument .ChangeType ;
4042import com .google .cloud .firestore .spi .v1 .FirestoreRpc ;
@@ -393,6 +395,19 @@ public void queryWatchRetriesBasedOnErrorCode() throws InterruptedException {
393395 }
394396 }
395397
398+ @ Test
399+ public void queryWatchRetriesOnInternalException () throws InterruptedException {
400+ addQueryListener ();
401+ awaitAddTarget ();
402+ send (addTarget ());
403+ destroy (new InternalException (null , GrpcStatusCode .of (Code .INTERNAL ), true ));
404+ awaitAddTarget ();
405+ send (addTarget ());
406+ send (current ());
407+ send (snapshot ());
408+ awaitQuerySnapshot ();
409+ }
410+
396411 @ Test
397412 public void queryWatchHandlesDocumentChange () throws InterruptedException {
398413 addQueryListener ();
@@ -991,7 +1006,11 @@ private void send(ListenResponse response) {
9911006 }
9921007
9931008 private void destroy (Code code ) {
994- streamObserverCapture .getValue ().onError (new StatusException (io .grpc .Status .fromCode (code )));
1009+ destroy (new StatusException (io .grpc .Status .fromCode (code )));
1010+ }
1011+
1012+ private void destroy (Exception e ) {
1013+ streamObserverCapture .getValue ().onError (e );
9951014 }
9961015
9971016 private void close () {
You can’t perform that action at this time.
0 commit comments