@@ -111,6 +111,27 @@ public class ComputeEngineCredentials extends GoogleCredentials
111111 static final int MAX_COMPUTE_PING_TRIES = 3 ;
112112 static final int COMPUTE_PING_CONNECTION_TIMEOUT_MS = 500 ;
113113
114+ private static final String METADATA_FLAVOR = "Metadata-Flavor" ;
115+ private static final String GOOGLE = "Google" ;
116+ private static final String WINDOWS = "windows" ;
117+ private static final String LINUX = "linux" ;
118+
119+ private static final String PARSE_ERROR_PREFIX = "Error parsing token refresh response. " ;
120+ private static final String PARSE_ERROR_ACCOUNT = "Error parsing service account response. " ;
121+ private static final long serialVersionUID = -4113476462526554235L ;
122+
123+ private final String transportFactoryClassName ;
124+
125+ private final Collection <String > scopes ;
126+
127+ private final GoogleAuthTransport transport ;
128+ private final BindingEnforcement bindingEnforcement ;
129+
130+ private transient HttpTransportFactory transportFactory ;
131+ private transient String serviceAccountEmail ;
132+
133+ private String universeDomainFromMetadata = null ;
134+
114135 /**
115136 * Experimental Feature.
116137 *
@@ -172,29 +193,6 @@ public String getLabel() {
172193 }
173194 }
174195
175- private static final String METADATA_FLAVOR = "Metadata-Flavor" ;
176- private static final String GOOGLE = "Google" ;
177- private static final String WINDOWS = "windows" ;
178- private static final String LINUX = "linux" ;
179-
180- private static final String PARSE_ERROR_PREFIX = "Error parsing token refresh response. " ;
181- private static final String PARSE_ERROR_ACCOUNT = "Error parsing service account response. " ;
182- private static final long serialVersionUID = -4113476462526554235L ;
183-
184- private final String transportFactoryClassName ;
185-
186- private final Collection <String > scopes ;
187-
188- private final GoogleAuthTransport transport ;
189- private final BindingEnforcement bindingEnforcement ;
190-
191- private transient HttpTransportFactory transportFactory ;
192- private transient String serviceAccountEmail ;
193-
194- private final boolean shouldCheckMDSOnInitialization ;
195-
196- private String universeDomainFromMetadata = null ;
197-
198196 /**
199197 * An internal constructor
200198 *
@@ -223,18 +221,6 @@ private ComputeEngineCredentials(ComputeEngineCredentials.Builder builder) {
223221 this .transport = builder .getGoogleAuthTransport ();
224222 this .bindingEnforcement = builder .getBindingEnforcement ();
225223 this .name = GoogleCredentialsInfo .COMPUTE_ENGINE_CREDENTIALS .getCredentialName ();
226- this .shouldCheckMDSOnInitialization = builder .shouldCheckMDSOnInitialization ;
227- try {
228- if (shouldCheckMDSOnInitialization
229- && !Boolean .parseBoolean (System .getenv (DefaultCredentialsProvider .NO_GCE_CHECK_ENV_VAR ))
230- && checkStaticGceDetection (new DefaultCredentialsProvider ())) {
231- this .serviceAccountEmail = getDefaultServiceAccount ();
232- this .principal = this .serviceAccountEmail ;
233- }
234- } catch (IOException e ) {
235- // This should never happen since we do a passive check for MDS. However, if this does fail,
236- // we mo-op as MDS is not available yet and should not fail initialization
237- }
238224 }
239225
240226 @ Override
@@ -701,10 +687,6 @@ public static Builder newBuilder() {
701687 return new Builder ();
702688 }
703689
704- static Builder newTestBuilder () {
705- return newBuilder ().setShouldCheckMDSOnInitialization (false );
706- }
707-
708690 /**
709691 * Returns the email address associated with the GCE default service account.
710692 *
@@ -797,8 +779,6 @@ public static class Builder extends GoogleCredentials.Builder {
797779 private GoogleAuthTransport transport ;
798780 private BindingEnforcement bindingEnforcement ;
799781
800- private boolean shouldCheckMDSOnInitialization = true ;
801-
802782 protected Builder () {
803783 setRefreshMargin (COMPUTE_REFRESH_MARGIN );
804784 setExpirationMargin (COMPUTE_EXPIRATION_MARGIN );
@@ -808,7 +788,6 @@ protected Builder(ComputeEngineCredentials credentials) {
808788 super (credentials );
809789 this .transportFactory = credentials .transportFactory ;
810790 this .scopes = credentials .scopes ;
811- this .shouldCheckMDSOnInitialization = credentials .shouldCheckMDSOnInitialization ;
812791 }
813792
814793 @ CanIgnoreReturnValue
@@ -863,11 +842,6 @@ public Builder setBindingEnforcement(BindingEnforcement bindingEnforcement) {
863842 return this ;
864843 }
865844
866- Builder setShouldCheckMDSOnInitialization (boolean shouldCheckMDSOnInitialization ) {
867- this .shouldCheckMDSOnInitialization = shouldCheckMDSOnInitialization ;
868- return this ;
869- }
870-
871845 public HttpTransportFactory getHttpTransportFactory () {
872846 return transportFactory ;
873847 }
0 commit comments