Skip to content

Commit 2ef47e8

Browse files
author
Ajay Kannan
committed
Use NetHttpTransport when running on Compute
1 parent 539ac61 commit 2ef47e8

1 file changed

Lines changed: 0 additions & 20 deletions

File tree

gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121
import static java.nio.charset.StandardCharsets.UTF_8;
2222

2323
import com.google.api.client.extensions.appengine.http.UrlFetchTransport;
24-
import com.google.api.client.googleapis.compute.ComputeCredential;
25-
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
2624
import com.google.api.client.http.HttpRequest;
2725
import com.google.api.client.http.HttpRequestInitializer;
2826
import com.google.api.client.http.HttpTransport;
2927
import com.google.api.client.http.javanet.NetHttpTransport;
30-
import com.google.api.client.json.jackson.JacksonFactory;
3128
import com.google.common.collect.Iterables;
3229
import com.google.gcloud.spi.ServiceRpcFactory;
3330

@@ -44,7 +41,6 @@
4441
import java.lang.reflect.Method;
4542
import java.net.HttpURLConnection;
4643
import java.net.URL;
47-
import java.security.GeneralSecurityException;
4844
import java.util.Enumeration;
4945
import java.util.Locale;
5046
import java.util.Objects;
@@ -113,24 +109,8 @@ public HttpTransport create() {
113109
// Maybe not on App Engine
114110
}
115111
}
116-
// Consider Compute
117-
try {
118-
return getComputeHttpTransport();
119-
} catch (Exception e) {
120-
// Maybe not on GCE
121-
}
122112
return new NetHttpTransport();
123113
}
124-
125-
private static HttpTransport getComputeHttpTransport()
126-
throws IOException, GeneralSecurityException {
127-
NetHttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
128-
// Try to connect using Google Compute Engine service account credentials.
129-
ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());
130-
// Force token refresh to detect if we are running on Google Compute Engine.
131-
credential.refreshToken();
132-
return transport;
133-
}
134114
}
135115

136116
/**

0 commit comments

Comments
 (0)