File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
samples/snippets/src/test/java/com/example/spanner Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1919import static com .google .common .truth .Truth .assertThat ;
2020import static org .junit .Assert .assertTrue ;
2121
22+ import com .google .api .gax .rpc .FailedPreconditionException ;
2223import com .google .cloud .Timestamp ;
2324import com .google .cloud .spanner .DatabaseId ;
2425import com .google .cloud .spanner .ErrorCode ;
@@ -643,8 +644,13 @@ private static void deleteAllBackups(String instanceId) throws InterruptedExcept
643644 attempts ++;
644645 databaseAdminClient .deleteBackup (backup .getName ());
645646 break ;
646- } catch (SpannerException e ) {
647- if (e .getErrorCode () == ErrorCode .FAILED_PRECONDITION
647+ } catch (SpannerException | FailedPreconditionException e ) {
648+ ErrorCode errorCode = ErrorCode .FAILED_PRECONDITION ;
649+
650+ if (e instanceof SpannerException ) {
651+ errorCode = ((SpannerException ) e ).getErrorCode ();
652+ }
653+ if (errorCode == ErrorCode .FAILED_PRECONDITION
648654 && e .getMessage ()
649655 .contains (
650656 "Please try deleting the backup once the restore or post-restore optimize "
You can’t perform that action at this time.
0 commit comments