Skip to content

Commit 3a36865

Browse files
committed
Removed hardcoded class list for Android
1 parent 76e9e8f commit 3a36865

File tree

2 files changed

+2
-48
lines changed

2 files changed

+2
-48
lines changed

xds/src/main/java/io/grpc/xds/XdsCredentialsRegistry.java

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121

2222
import com.google.common.annotations.VisibleForTesting;
23+
import com.google.common.collect.ImmutableList;
2324
import com.google.common.collect.ImmutableMap;
2425
import com.google.errorprone.annotations.concurrent.GuardedBy;
2526
import io.grpc.InternalServiceProviders;
26-
import java.util.ArrayList;
27-
import java.util.Collections;
2827
import java.util.HashMap;
2928
import java.util.LinkedHashSet;
3029
import java.util.List;
3130
import java.util.Map;
32-
import java.util.logging.Level;
3331
import java.util.logging.Logger;
3432
import javax.annotation.Nullable;
3533
import javax.annotation.concurrent.ThreadSafe;
@@ -109,7 +107,7 @@ public static synchronized XdsCredentialsRegistry getDefaultRegistry() {
109107
if (instance == null) {
110108
List<XdsCredentialsProvider> providerList = InternalServiceProviders.loadAll(
111109
XdsCredentialsProvider.class,
112-
getHardCodedClasses(),
110+
ImmutableList.of(),
113111
XdsCredentialsProvider.class.getClassLoader(),
114112
new XdsCredentialsProviderPriorityAccessor());
115113
if (providerList.isEmpty()) {
@@ -147,39 +145,6 @@ public synchronized XdsCredentialsProvider getProvider(String name) {
147145
return effectiveProviders.get(checkNotNull(name, "name"));
148146
}
149147

150-
@VisibleForTesting
151-
static List<Class<?>> getHardCodedClasses() {
152-
// Class.forName(String) is used to remove the need for ProGuard configuration. Note that
153-
// ProGuard does not detect usages of Class.forName(String, boolean, ClassLoader):
154-
// https://sourceforge.net/p/proguard/bugs/418/
155-
ArrayList<Class<?>> list = new ArrayList<>();
156-
try {
157-
list.add(Class.forName("io.grpc.xds.internal.GoogleDefaultXdsCredentialsProvider"));
158-
} catch (ClassNotFoundException e) {
159-
logger.log(Level.WARNING, "Unable to find GoogleDefaultXdsCredentialsProvider", e);
160-
}
161-
162-
try {
163-
list.add(Class.forName("io.grpc.xds.internal.InsecureXdsCredentialsProvider"));
164-
} catch (ClassNotFoundException e) {
165-
logger.log(Level.WARNING, "Unable to find InsecureXdsCredentialsProvider", e);
166-
}
167-
168-
try {
169-
list.add(Class.forName("io.grpc.xds.internal.TlsXdsCredentialsProvider"));
170-
} catch (ClassNotFoundException e) {
171-
logger.log(Level.WARNING, "Unable to find TlsXdsCredentialsProvider", e);
172-
}
173-
174-
try {
175-
list.add(Class.forName("io.grpc.xds.internal.JwtTokenFileXdsCredentialsProvider"));
176-
} catch (ClassNotFoundException e) {
177-
logger.log(Level.WARNING, "Unable to find JwtTokenFileXdsCredentialsProvider", e);
178-
}
179-
180-
return Collections.unmodifiableList(list);
181-
}
182-
183148
private static final class XdsCredentialsProviderPriorityAccessor
184149
implements InternalServiceProviders.PriorityAccessor<XdsCredentialsProvider> {
185150
@Override

xds/src/test/java/io/grpc/xds/XdsCredentialsRegistryTest.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import io.grpc.xds.internal.InsecureXdsCredentialsProvider;
3131
import io.grpc.xds.internal.JwtTokenFileXdsCredentialsProvider;
3232
import io.grpc.xds.internal.TlsXdsCredentialsProvider;
33-
import java.util.List;
3433
import java.util.Map;
3534
import org.junit.Test;
3635
import org.junit.runner.RunWith;
@@ -149,16 +148,6 @@ public void defaultRegistry_providers() {
149148
.isEqualTo(TlsXdsCredentialsProvider.class);
150149
}
151150

152-
@Test
153-
public void getClassesViaHardcoded_classesPresent() throws Exception {
154-
List<Class<?>> classes = XdsCredentialsRegistry.getHardCodedClasses();
155-
assertThat(classes).containsExactly(
156-
GoogleDefaultXdsCredentialsProvider.class,
157-
InsecureXdsCredentialsProvider.class,
158-
JwtTokenFileXdsCredentialsProvider.class,
159-
TlsXdsCredentialsProvider.class);
160-
}
161-
162151
@Test
163152
public void getProvider_null() {
164153
try {

0 commit comments

Comments
 (0)