Skip to content

Commit 369f87b

Browse files
ejona86sergiitk
authored andcommitted
Revert "auth: Add support for Retryable interface"
This reverts commit 0963f31. This causes dependency problems when importing into Google, as google-auth-library-java needs to be upgraded and that requires an upgrade to google-http-java-client to bring in googleapis/google-http-java-client#1505 . Reverting for now and will roll forward once those upgrades are performed.
1 parent 7dc4fc9 commit 369f87b

File tree

6 files changed

+15
-50
lines changed

6 files changed

+15
-50
lines changed

auth/src/main/java/io/grpc/auth/GoogleAuthLibraryCallCredentials.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
import com.google.auth.Credentials;
2222
import com.google.auth.RequestMetadataCallback;
23-
import com.google.auth.Retryable;
2423
import com.google.common.annotations.VisibleForTesting;
2524
import com.google.common.io.BaseEncoding;
2625
import io.grpc.Metadata;
2726
import io.grpc.MethodDescriptor;
2827
import io.grpc.SecurityLevel;
2928
import io.grpc.Status;
3029
import io.grpc.StatusException;
30+
import java.io.IOException;
3131
import java.lang.reflect.InvocationTargetException;
3232
import java.lang.reflect.Method;
3333
import java.net.URI;
@@ -133,8 +133,8 @@ public void onSuccess(Map<String, List<String>> metadata) {
133133

134134
@Override
135135
public void onFailure(Throwable e) {
136-
if (e instanceof Retryable && ((Retryable) e).isRetryable()) {
137-
// Let the call be retried with UNAVAILABLE.
136+
if (e instanceof IOException) {
137+
// Since it's an I/O failure, let the call be retried with UNAVAILABLE.
138138
applier.fail(Status.UNAVAILABLE
139139
.withDescription("Credentials failed to obtain metadata")
140140
.withCause(e));

auth/src/test/java/io/grpc/auth/GoogleAuthLibraryCallCredentialsTest.java

+2-38
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import com.google.auth.Credentials;
3232
import com.google.auth.RequestMetadataCallback;
33-
import com.google.auth.Retryable;
3433
import com.google.auth.http.HttpTransportFactory;
3534
import com.google.auth.oauth2.AccessToken;
3635
import com.google.auth.oauth2.GoogleCredentials;
@@ -192,9 +191,8 @@ public void invalidBase64() throws Exception {
192191
}
193192

194193
@Test
195-
public void credentialsFailsWithRetryableRetryableException() throws Exception {
196-
boolean retryable = true;
197-
Exception exception = new RetryableException(retryable);
194+
public void credentialsFailsWithIoException() throws Exception {
195+
Exception exception = new IOException("Broken");
198196
when(credentials.getRequestMetadata(eq(expectedUri))).thenThrow(exception);
199197

200198
GoogleAuthLibraryCallCredentials callCredentials =
@@ -208,23 +206,6 @@ public void credentialsFailsWithRetryableRetryableException() throws Exception {
208206
assertEquals(exception, status.getCause());
209207
}
210208

211-
@Test
212-
public void credentialsFailsWithUnretryableRetryableException() throws Exception {
213-
boolean retryable = false;
214-
Exception exception = new RetryableException(retryable);
215-
when(credentials.getRequestMetadata(eq(expectedUri))).thenThrow(exception);
216-
217-
GoogleAuthLibraryCallCredentials callCredentials =
218-
new GoogleAuthLibraryCallCredentials(credentials);
219-
callCredentials.applyRequestMetadata(new RequestInfoImpl(), executor, applier);
220-
221-
verify(credentials).getRequestMetadata(eq(expectedUri));
222-
verify(applier).fail(statusCaptor.capture());
223-
Status status = statusCaptor.getValue();
224-
assertEquals(Status.Code.UNAUTHENTICATED, status.getCode());
225-
assertEquals(exception, status.getCause());
226-
}
227-
228209
@Test
229210
public void credentialsFailsWithRuntimeException() throws Exception {
230211
Exception exception = new RuntimeException("Broken");
@@ -472,21 +453,4 @@ public Attributes getTransportAttrs() {
472453
return Attributes.EMPTY;
473454
}
474455
}
475-
476-
private static class RetryableException extends IOException implements Retryable {
477-
private final boolean retryable;
478-
479-
public RetryableException(boolean retryable) {
480-
super("Broken");
481-
this.retryable = retryable;
482-
}
483-
484-
@Override public boolean isRetryable() {
485-
return retryable;
486-
}
487-
488-
@Override public int getRetryCount() {
489-
return 0;
490-
}
491-
}
492456
}

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ subprojects {
5757

5858
nettyVersion = '4.1.72.Final'
5959
guavaVersion = '31.0.1-android'
60-
googleauthVersion = '1.5.3'
60+
googleauthVersion = '1.4.0'
6161
protobufVersion = '3.19.2'
6262
protocVersion = protobufVersion
6363
opencensusVersion = '0.28.0'

gcp-observability/build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ dependencies {
2828
implementation project(':grpc-protobuf'),
2929
project(':grpc-stub'),
3030
project(':grpc-alts'),
31-
libraries.google_auth_credentials,
3231
libraries.google_auth_oauth2_http,
3332
libraries.autovalue_annotation,
3433
libraries.perfmark,
3534
('com.google.guava:guava:31.0.1-jre'),
3635
('com.google.errorprone:error_prone_annotations:2.11.0'),
36+
('com.google.auth:google-auth-library-credentials:1.4.0'),
3737
('org.checkerframework:checker-qual:3.20.0'),
38-
('com.google.http-client:google-http-client:1.41.3'),
39-
('com.google.http-client:google-http-client-gson:1.41.3'),
38+
('com.google.auto.value:auto-value-annotations:1.9'),
39+
('com.google.http-client:google-http-client:1.41.0'),
40+
('com.google.http-client:google-http-client-gson:1.41.0'),
4041
('com.google.api.grpc:proto-google-common-protos:2.7.1'),
4142
("com.google.cloud:google-cloud-logging:${cloudLoggingVersion}")
4243

interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import io.opencensus.trace.Span;
101101
import io.opencensus.trace.SpanContext;
102102
import io.opencensus.trace.Tracing;
103+
import io.opencensus.trace.unsafe.ContextUtils;
103104
import java.io.ByteArrayInputStream;
104105
import java.io.ByteArrayOutputStream;
105106
import java.io.IOException;
@@ -1546,7 +1547,6 @@ public void customMetadata() throws Exception {
15461547
Collections.singleton(streamingRequest), Collections.singleton(goldenStreamingResponse));
15471548
}
15481549

1549-
@SuppressWarnings("deprecation")
15501550
@Test(timeout = 10000)
15511551
public void censusContextsPropagated() {
15521552
Assume.assumeTrue("Skip the test because server is not in the same process.", server != null);
@@ -1561,7 +1561,7 @@ public void censusContextsPropagated() {
15611561
.emptyBuilder()
15621562
.putLocal(StatsTestUtils.EXTRA_TAG, TagValue.create("extra value"))
15631563
.build());
1564-
ctx = io.opencensus.trace.unsafe.ContextUtils.withValue(ctx, clientParentSpan);
1564+
ctx = ContextUtils.withValue(ctx, clientParentSpan);
15651565
Context origCtx = ctx.attach();
15661566
try {
15671567
blockingStub.unaryCall(SimpleRequest.getDefaultInstance());
@@ -1581,7 +1581,7 @@ public void censusContextsPropagated() {
15811581
}
15821582
assertTrue("tag not found", tagFound);
15831583

1584-
Span span = io.opencensus.trace.unsafe.ContextUtils.getValue(serverCtx);
1584+
Span span = ContextUtils.getValue(serverCtx);
15851585
assertNotNull(span);
15861586
SpanContext spanContext = span.getContext();
15871587
assertEquals(clientParentSpan.getContext().getTraceId(), spanContext.getTraceId());

repositories.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1212
IO_GRPC_GRPC_JAVA_ARTIFACTS = [
1313
"com.google.android:annotations:4.1.1.4",
1414
"com.google.api.grpc:proto-google-common-protos:2.0.1",
15-
"com.google.auth:google-auth-library-credentials:1.5.3",
16-
"com.google.auth:google-auth-library-oauth2-http:1.5.3",
15+
"com.google.auth:google-auth-library-credentials:0.22.0",
16+
"com.google.auth:google-auth-library-oauth2-http:0.22.0",
1717
"com.google.code.findbugs:jsr305:3.0.2",
1818
"com.google.code.gson:gson:2.8.9",
1919
"com.google.auto.value:auto-value:1.7.4",

0 commit comments

Comments
 (0)