Skip to content

Commit

Permalink
changes for review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zpencer committed Apr 27, 2017
1 parent cfde420 commit 17456bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,6 @@ public void setEnableTracing(boolean enabled) {
@Override
public ManagedChannel build() {
ClientTransportFactory transportFactory = buildTransportFactory();
if (authorityOverride != null) {
transportFactory = new AuthorityOverridingTransportFactory(
transportFactory, authorityOverride);
}
NameResolver.Factory nameResolverFactory = this.nameResolverFactory;
if (nameResolverFactory == null) {
// Avoid loading the provider unless necessary, as a way to workaround a possibly-costly
Expand Down Expand Up @@ -386,29 +382,6 @@ public Executor returnObject(Object returned) {
}
}

private static class AuthorityOverridingTransportFactory implements ClientTransportFactory {
final ClientTransportFactory factory;
final String authorityOverride;

AuthorityOverridingTransportFactory(
ClientTransportFactory factory, String authorityOverride) {
this.factory = Preconditions.checkNotNull(factory, "factory should not be null");
this.authorityOverride = Preconditions.checkNotNull(
authorityOverride, "authorityOverride should not be null");
}

@Override
public ConnectionClientTransport newClientTransport(SocketAddress serverAddress,
String authority, @Nullable String userAgent) {
return factory.newClientTransport(serverAddress, authorityOverride, userAgent);
}

@Override
public void close() {
factory.close();
}
}

private static class DirectAddressNameResolverFactory extends NameResolver.Factory {
final SocketAddress address;
final String authority;
Expand Down Expand Up @@ -449,12 +422,13 @@ public String getDefaultScheme() {
* functionality.
*/
@VisibleForTesting
protected static class OverrideAuthorityNameResolverFactory extends NameResolver.Factory {
final NameResolver.Factory delegate;
final String authorityOverride;
static class OverrideAuthorityNameResolverFactory extends NameResolver.Factory {
private final NameResolver.Factory delegate;
private final String authorityOverride;

/**
* Constructor for the {@link NameResolver.Factory}
*
* @param delegate The actual underlying factory that will produce the a {@link NameResolver}
* @param authorityOverride The authority that will be returned by {@link
* NameResolver#getServiceAuthority()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@

import io.grpc.Attributes;
import io.grpc.NameResolver;

import java.net.InetSocketAddress;
import java.net.URI;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down

0 comments on commit 17456bb

Please sign in to comment.