File tree Expand file tree Collapse file tree
google-cloud-core/src/main/java/com/google/cloud
google-cloud-logging/src/main/java/com/google/cloud/logging/spi/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import static com .google .common .base .MoreObjects .firstNonNull ;
2020import static com .google .common .base .Preconditions .checkArgument ;
2121import static com .google .common .base .Preconditions .checkNotNull ;
22- import static java .nio .charset .StandardCharsets .UTF_8 ;
2322
2423import com .google .api .core .ApiClock ;
2524import com .google .api .core .CurrentMillisClock ;
3736import java .io .FileReader ;
3837import java .io .IOException ;
3938import java .io .InputStream ;
40- import java .io .InputStreamReader ;
4139import java .io .ObjectInputStream ;
4240import java .io .Serializable ;
4341import java .lang .reflect .Method ;
44- import java .net .HttpURLConnection ;
45- import java .net .URL ;
4642import java .nio .charset .Charset ;
4743import java .util .Locale ;
4844import java .util .Objects ;
@@ -461,6 +457,17 @@ public Credentials getCredentials() {
461457 return credentials ;
462458 }
463459
460+ /**
461+ * Returns whether the credential is {@code NoCredentials} instance
462+ * @return true if credential is a {@code NoCredentials} instance, false if not
463+ */
464+ public boolean credentialIsNoCredentialInstance () {
465+ if (credentials != null ) {
466+ return credentials .equals (NoCredentials .getInstance ());
467+ }
468+ return false ;
469+ }
470+
464471 /**
465472 * Returns the authentication credentials. If required, credentials are scoped.
466473 */
Original file line number Diff line number Diff line change 2828import com .google .api .gax .grpc .UnaryCallSettings ;
2929import com .google .cloud .GrpcTransportOptions ;
3030import com .google .cloud .GrpcTransportOptions .ExecutorFactory ;
31- import com .google .cloud .NoCredentials ;
3231import com .google .cloud .logging .LoggingException ;
3332import com .google .cloud .logging .LoggingOptions ;
3433import com .google .logging .v2 .CreateLogMetricRequest ;
@@ -82,7 +81,7 @@ public GrpcLoggingRpc(LoggingOptions options) throws IOException {
8281 ChannelProvider channelProvider ;
8382 // todo(mziccard): ChannelProvider should support null/absent credentials for testing
8483 if (options .getHost ().contains ("localhost" )
85- || options .getCredentials (). equals ( NoCredentials . getInstance () )) {
84+ || options .credentialIsNoCredentialInstance ( )) {
8685 ManagedChannel managedChannel = ManagedChannelBuilder .forTarget (options .getHost ())
8786 .usePlaintext (true )
8887 .executor (executor )
You can’t perform that action at this time.
0 commit comments