Skip to content

Commit 820b8ce

Browse files
committed
fixed exception I was catching
1 parent 4b5b0b5 commit 820b8ce

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

auth/src/test/java/com/google/cloud/auth/samples/AuthExampleIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.api.apikeys.v2.Key;
2323
import com.google.cloud.ServiceOptions;
2424
import io.grpc.StatusRuntimeException;
25+
import com.google.api.gax.rpc.InvalidArgumentException;
2526
import java.io.ByteArrayOutputStream;
2627
import java.io.IOException;
2728
import 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
}

0 commit comments

Comments
 (0)