Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.cloud;

import com.google.auth.oauth2.OAuth2Credentials;

import java.io.ObjectStreamException;

/**
Expand All @@ -38,4 +37,12 @@ private Object readResolve() throws ObjectStreamException {
public static NoCredentials getInstance() {
return INSTANCE;
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof NoCredentials)) {
return false;
}
return this == obj;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.api.core.ApiClock;
import com.google.api.core.CurrentMillisClock;
Expand All @@ -37,12 +36,9 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.cloud;

import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertSame;
Expand Down Expand Up @@ -231,6 +232,9 @@ public void testBuilder() {
@Test
public void testBuilderNoCredentials() {
assertEquals(NoCredentials.getInstance(), OPTIONS_NO_CREDENTIALS.getCredentials());
assertTrue(NoCredentials.getInstance().equals(OPTIONS_NO_CREDENTIALS.getCredentials()));
assertFalse(NoCredentials.getInstance().equals(OPTIONS.getCredentials()));
assertFalse(NoCredentials.getInstance().equals(null));
assertSame(TEST_CLOCK, OPTIONS_NO_CREDENTIALS.getClock());
assertEquals("host", OPTIONS_NO_CREDENTIALS.getHost());
assertEquals("project-id", OPTIONS_NO_CREDENTIALS.getProjectId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public GrpcLoggingRpc(LoggingOptions options) throws IOException {
ChannelProvider channelProvider;
// todo(mziccard): ChannelProvider should support null/absent credentials for testing
if (options.getHost().contains("localhost")
|| options.getCredentials().equals(NoCredentials.getInstance())) {
|| NoCredentials.getInstance().equals(options.getCredentials())) {
ManagedChannel managedChannel = ManagedChannelBuilder.forTarget(options.getHost())
.usePlaintext(true)
.executor(executor)
Expand Down