File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
auth/src/test/java/com/google/cloud/auth/samples Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 2222import com .google .api .apikeys .v2 .Key ;
2323import com .google .cloud .ServiceOptions ;
2424import io .grpc .StatusRuntimeException ;
25+ import com .google .api .gax .rpc .InvalidArgumentException ;
2526import java .io .ByteArrayOutputStream ;
2627import java .io .IOException ;
2728import java .io .PrintStream ;
@@ -91,12 +92,14 @@ static String authenticateUsingApiKeyWithRetry(String apiKey) throws IOException
9192 for (int i = 0 ; i < retries ; i ++) {
9293 try {
9394 return ApiKeyAuthExample .authenticateUsingApiKey (apiKey );
94- } catch (StatusRuntimeException e ) {
95+ } catch (StatusRuntimeException | InvalidArgumentException e ) {
9596 if (e .getMessage ().contains ("API key expired" )) {
9697 System .out .println ("API key not yet active, retrying..." );
9798 try {
9899 Thread .sleep (delay );
99- } catch (InterruptedException ignored ) { }
100+ } catch (InterruptedException ignored ) {
101+ // ignore iterrupted exception and retry test
102+ }
100103 } else {
101104 throw e ;
102105 }
You can’t perform that action at this time.
0 commit comments