File tree Expand file tree Collapse file tree
main/java/com/google/cloud
test/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 1717package com .google .cloud ;
1818
1919import com .google .auth .oauth2 .OAuth2Credentials ;
20-
2120import java .io .ObjectStreamException ;
2221
2322/**
@@ -38,4 +37,12 @@ private Object readResolve() throws ObjectStreamException {
3837 public static NoCredentials getInstance () {
3938 return INSTANCE ;
4039 }
40+
41+ @ Override
42+ public boolean equals (Object obj ) {
43+ if (!(obj instanceof NoCredentials )) {
44+ return false ;
45+ }
46+ return this == obj ;
47+ }
4148}
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 ;
Original file line number Diff line number Diff line change 1616
1717package com .google .cloud ;
1818
19+ import static junit .framework .TestCase .assertFalse ;
1920import static org .junit .Assert .assertEquals ;
2021import static org .junit .Assert .assertNotEquals ;
2122import static org .junit .Assert .assertSame ;
@@ -231,6 +232,9 @@ public void testBuilder() {
231232 @ Test
232233 public void testBuilderNoCredentials () {
233234 assertEquals (NoCredentials .getInstance (), OPTIONS_NO_CREDENTIALS .getCredentials ());
235+ assertTrue (NoCredentials .getInstance ().equals (OPTIONS_NO_CREDENTIALS .getCredentials ()));
236+ assertFalse (NoCredentials .getInstance ().equals (OPTIONS .getCredentials ()));
237+ assertFalse (NoCredentials .getInstance ().equals (null ));
234238 assertSame (TEST_CLOCK , OPTIONS_NO_CREDENTIALS .getClock ());
235239 assertEquals ("host" , OPTIONS_NO_CREDENTIALS .getHost ());
236240 assertEquals ("project-id" , OPTIONS_NO_CREDENTIALS .getProjectId ());
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ public GrpcLoggingRpc(LoggingOptions options) throws IOException {
8282 ChannelProvider channelProvider ;
8383 // todo(mziccard): ChannelProvider should support null/absent credentials for testing
8484 if (options .getHost ().contains ("localhost" )
85- || options . getCredentials () == NoCredentials . getInstance ( )) {
85+ || NoCredentials . getInstance (). equals ( options . getCredentials () )) {
8686 ManagedChannel managedChannel = ManagedChannelBuilder .forTarget (options .getHost ())
8787 .usePlaintext (true )
8888 .executor (executor )
You can’t perform that action at this time.
0 commit comments