all: fix minor JavaStyle errors found in code sync

This commit is contained in:
dapengzhang0 2016-10-04 11:03:40 -07:00
parent cad7124c27
commit 4e5765a93f
7 changed files with 30 additions and 35 deletions

View File

@ -90,8 +90,8 @@ public class CallCredentialsApplyingTest {
@Mock
private SocketAddress address;
private static final String authority = "testauthority";
private static final String userAgent = "testuseragent";
private static final String AUTHORITY = "testauthority";
private static final String USER_AGENT = "testuseragent";
private static final Attributes.Key<String> ATTR_KEY = Attributes.Key.of("somekey");
private static final String ATTR_VALUE = "somevalue";
private static final MethodDescriptor<String, Integer> method = MethodDescriptor.create(
@ -112,16 +112,16 @@ public class CallCredentialsApplyingTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
origHeaders.put(ORIG_HEADER_KEY, ORIG_HEADER_VALUE);
when(mockTransportFactory.newClientTransport(address, authority, userAgent))
when(mockTransportFactory.newClientTransport(address, AUTHORITY, USER_AGENT))
.thenReturn(mockTransport);
when(mockTransport.newStream(same(method), any(Metadata.class), any(CallOptions.class)))
.thenReturn(mockStream);
ClientTransportFactory transportFactory = new CallCredentialsApplyingTransportFactory(
mockTransportFactory, mockExecutor);
transport = (ForwardingConnectionClientTransport) transportFactory.newClientTransport(
address, authority, userAgent);
address, AUTHORITY, USER_AGENT);
callOptions = CallOptions.DEFAULT.withCallCredentials(mockCreds);
verify(mockTransportFactory).newClientTransport(address, authority, userAgent);
verify(mockTransportFactory).newClientTransport(address, AUTHORITY, USER_AGENT);
assertSame(mockTransport, transport.delegate());
}
@ -137,7 +137,7 @@ public class CallCredentialsApplyingTest {
any(MetadataApplier.class));
Attributes attrs = attrsCaptor.getValue();
assertSame(ATTR_VALUE, attrs.get(ATTR_KEY));
assertSame(authority, attrs.get(CallCredentials.ATTR_AUTHORITY));
assertSame(AUTHORITY, attrs.get(CallCredentials.ATTR_AUTHORITY));
assertSame(SecurityLevel.NONE, attrs.get(CallCredentials.ATTR_SECURITY_LEVEL));
}

View File

@ -62,7 +62,6 @@ import io.grpc.ResolvedServerInfo;
import io.grpc.ResolvedServerInfoGroup;
import io.grpc.Status;
import io.grpc.StringMarshaller;
import io.grpc.TransportManager.InterimTransport;
import io.grpc.TransportManager.OobTransportProvider;
import io.grpc.TransportManager;
import io.grpc.internal.TestUtils.MockClientTransportInfo;
@ -98,8 +97,8 @@ import java.util.concurrent.TimeUnit;
public class ManagedChannelImplIdlenessTest {
private final FakeClock timer = new FakeClock();
private final FakeClock executor = new FakeClock();
private static final String authority = "fakeauthority";
private static final String userAgent = "fakeagent";
private static final String AUTHORITY = "fakeauthority";
private static final String USER_AGENT = "fakeagent";
private static final long IDLE_TIMEOUT_SECONDS = 30;
private ManagedChannelImpl channel;
@ -128,7 +127,7 @@ public class ManagedChannelImplIdlenessTest {
when(mockLoadBalancerFactory
.newLoadBalancer(anyString(), Matchers.<TransportManager<ClientTransport>>any()))
.thenReturn(mockLoadBalancer);
when(mockNameResolver.getServiceAuthority()).thenReturn(authority);
when(mockNameResolver.getServiceAuthority()).thenReturn(AUTHORITY);
when(mockNameResolverFactory
.newNameResolver(any(URI.class), any(Attributes.class)))
.thenReturn(mockNameResolver);
@ -138,7 +137,7 @@ public class ManagedChannelImplIdlenessTest {
mockTransportFactory, DecompressorRegistry.getDefaultInstance(),
CompressorRegistry.getDefaultInstance(), timerService, timer.getStopwatchSupplier(),
TimeUnit.SECONDS.toMillis(IDLE_TIMEOUT_SECONDS),
executor.getScheduledExecutorService(), userAgent,
executor.getScheduledExecutorService(), USER_AGENT,
Collections.<ClientInterceptor>emptyList());
newTransports = TestUtils.captureTransports(mockTransportFactory);
@ -187,7 +186,7 @@ public class ManagedChannelImplIdlenessTest {
// LoadBalancer is used right after created.
verify(mockLoadBalancer).pickTransport(any(Attributes.class));
verify(mockTransportFactory).newClientTransport(
addressGroup.getAddresses().get(0), authority, userAgent);
addressGroup.getAddresses().get(0), AUTHORITY, USER_AGENT);
// Simulate new address resolved
nameResolverListenerCaptor.getValue().onUpdate(servers, Attributes.EMPTY);
@ -202,13 +201,13 @@ public class ManagedChannelImplIdlenessTest {
for (EquivalentAddressGroup addressGroup : addressGroupList) {
channel.tm.getTransport(addressGroup);
verify(mockTransportFactory).newClientTransport(
addressGroup.getAddresses().get(0), authority, userAgent);
addressGroup.getAddresses().get(0), AUTHORITY, USER_AGENT);
}
ArrayList<MockClientTransportInfo> transports = new ArrayList<MockClientTransportInfo>();
newTransports.drainTo(transports);
assertEquals(addressGroupList.size(), transports.size());
InterimTransport<ClientTransport> interimTransport = channel.tm.createInterimTransport();
channel.tm.createInterimTransport();
// Without actually using these transports, will eventually enter idle mode
walkIntoIdleMode(transports);
@ -216,7 +215,6 @@ public class ManagedChannelImplIdlenessTest {
@Test
public void interimTransportHoldsOffIdleness() throws Exception {
final EquivalentAddressGroup addressGroup = addressGroupList.get(1);
doAnswer(new Answer<ClientTransport>() {
@Override
public ClientTransport answer(InvocationOnMock invocation) throws Throwable {
@ -321,7 +319,7 @@ public class ManagedChannelImplIdlenessTest {
assertSame(ManagedChannelImpl.IDLE_MODE_TRANSPORT,
channel.tm.getTransport(addressGroupList.get(0)));
OobTransportProvider<ClientTransport> oobProvider =
channel.tm.createOobTransportProvider(addressGroupList.get(0), "authority");
channel.tm.createOobTransportProvider(addressGroupList.get(0), AUTHORITY);
assertSame(ManagedChannelImpl.IDLE_MODE_TRANSPORT, oobProvider.get());
oobProvider.close();
verify(mockTransportFactory, never()).newClientTransport(

View File

@ -833,7 +833,6 @@ public class ManagedChannelImplTest {
@Test
public void informationPropagatedToNewStreamAndCallCredentials() {
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
Metadata headers = new Metadata();
CallOptions callOptions = CallOptions.DEFAULT.withCallCredentials(creds);
final Context.Key<String> testKey = Context.key("testing");
Context ctx = Context.current().withValue(testKey, "testValue");

View File

@ -89,8 +89,8 @@ import java.util.concurrent.TimeUnit;
@RunWith(JUnit4.class)
public class ManagedChannelImplTransportManagerTest {
private static final String authority = "fakeauthority";
private static final String userAgent = "mosaic";
private static final String AUTHORITY = "fakeauthority";
private static final String USER_AGENT = "mosaic";
private final ExecutorService executor = Executors.newSingleThreadExecutor();
private final MethodDescriptor<String, String> method = MethodDescriptor.create(
@ -120,7 +120,7 @@ public class ManagedChannelImplTransportManagerTest {
MockitoAnnotations.initMocks(this);
when(mockBackoffPolicyProvider.get()).thenReturn(mockBackoffPolicy);
when(mockNameResolver.getServiceAuthority()).thenReturn(authority);
when(mockNameResolver.getServiceAuthority()).thenReturn(AUTHORITY);
when(mockNameResolverFactory
.newNameResolver(any(URI.class), any(Attributes.class)))
.thenReturn(mockNameResolver);
@ -135,7 +135,7 @@ public class ManagedChannelImplTransportManagerTest {
mockTransportFactory, DecompressorRegistry.getDefaultInstance(),
CompressorRegistry.getDefaultInstance(), GrpcUtil.TIMER_SERVICE,
GrpcUtil.STOPWATCH_SUPPLIER, ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE,
executor, userAgent, Collections.<ClientInterceptor>emptyList());
executor, USER_AGENT, Collections.<ClientInterceptor>emptyList());
ArgumentCaptor<TransportManager<ClientTransport>> tmCaptor
= ArgumentCaptor.forClass(null);
@ -160,7 +160,7 @@ public class ManagedChannelImplTransportManagerTest {
SocketAddress addr = mock(SocketAddress.class);
EquivalentAddressGroup addressGroup = new EquivalentAddressGroup(addr);
ClientTransport t1 = tm.getTransport(addressGroup);
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr, authority, userAgent);
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr, AUTHORITY, USER_AGENT);
// The real transport
MockClientTransportInfo transportInfo = transports.poll(1, TimeUnit.SECONDS);
transportInfo.listener.transportReady();
@ -185,7 +185,7 @@ public class ManagedChannelImplTransportManagerTest {
// Pick the first transport
ClientTransport t1 = tm.getTransport(addressGroup);
assertNotNull(t1);
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr1, authority, userAgent);
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr1, AUTHORITY, USER_AGENT);
verify(mockBackoffPolicyProvider, times(backoffReset)).get();
// Fail the first transport, without setting it to ready
MockClientTransportInfo transportInfo = transports.poll(1, TimeUnit.SECONDS);
@ -197,7 +197,7 @@ public class ManagedChannelImplTransportManagerTest {
assertNotNull(t2);
t2.newStream(method, new Metadata(), callOptions);
// Will keep the previous back-off policy, and not consult back-off policy
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr2, authority, userAgent);
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr2, AUTHORITY, USER_AGENT);
verify(mockBackoffPolicyProvider, times(backoffReset)).get();
transportInfo = transports.poll(1, TimeUnit.SECONDS);
ClientTransport rt2 = transportInfo.transport;
@ -215,7 +215,7 @@ public class ManagedChannelImplTransportManagerTest {
ClientTransport t3 = tm.getTransport(addressGroup);
t3.newStream(method2, new Metadata(), callOptions2);
verify(mockTransportFactory, timeout(1000).times(2))
.newClientTransport(addr1, authority, userAgent);
.newClientTransport(addr1, AUTHORITY, USER_AGENT);
// Still no back-off policy creation, because an address succeeded.
verify(mockBackoffPolicyProvider, times(backoffReset)).get();
transportInfo = transports.poll(1, TimeUnit.SECONDS);
@ -249,7 +249,7 @@ public class ManagedChannelImplTransportManagerTest {
ClientTransport t1 = tm.getTransport(addressGroup);
assertNotNull(t1);
verify(mockTransportFactory, timeout(1000).times(++transportsAddr1))
.newClientTransport(addr1, authority, userAgent);
.newClientTransport(addr1, AUTHORITY, USER_AGENT);
// Back-off policy was unset initially.
verify(mockBackoffPolicyProvider, times(backoffReset)).get();
MockClientTransportInfo transportInfo = transports.poll(1, TimeUnit.SECONDS);
@ -263,7 +263,7 @@ public class ManagedChannelImplTransportManagerTest {
ClientTransport t2 = tm.getTransport(addressGroup);
assertNotNull(t2);
verify(mockTransportFactory, timeout(1000).times(++transportsAddr1))
.newClientTransport(addr1, authority, userAgent);
.newClientTransport(addr1, AUTHORITY, USER_AGENT);
// Back-off policy was not reset.
verify(mockBackoffPolicyProvider, times(backoffReset)).get();
transports.poll(1, TimeUnit.SECONDS).listener.transportShutdown(Status.UNAVAILABLE);
@ -273,7 +273,7 @@ public class ManagedChannelImplTransportManagerTest {
ClientTransport t3 = tm.getTransport(addressGroup);
assertNotNull(t3);
verify(mockTransportFactory, timeout(1000).times(++transportsAddr2))
.newClientTransport(addr2, authority, userAgent);
.newClientTransport(addr2, AUTHORITY, USER_AGENT);
// Back-off policy was not reset.
verify(mockBackoffPolicyProvider, times(backoffReset)).get();
transports.poll(1, TimeUnit.SECONDS).listener.transportShutdown(Status.UNAVAILABLE);
@ -285,7 +285,7 @@ public class ManagedChannelImplTransportManagerTest {
// If backoff's DelayedTransport is still active, this is necessary. Otherwise it would be racy.
t4.newStream(method, new Metadata(), CallOptions.DEFAULT.withWaitForReady());
verify(mockTransportFactory, timeout(1000).times(++transportsAddr1))
.newClientTransport(addr1, authority, userAgent);
.newClientTransport(addr1, AUTHORITY, USER_AGENT);
// Back-off policy was reset and consulted.
verify(mockBackoffPolicyProvider, times(++backoffReset)).get();
verify(mockBackoffPolicy, times(++backoffConsulted)).nextBackoffMillis();
@ -344,7 +344,7 @@ public class ManagedChannelImplTransportManagerTest {
ClientTransport t1 = p1.get();
assertNotNull(t1);
assertSame(t1, p1.get());
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr, oobAuthority, userAgent);
verify(mockTransportFactory, timeout(1000)).newClientTransport(addr, oobAuthority, USER_AGENT);
MockClientTransportInfo transportInfo1 = transports.poll(1, TimeUnit.SECONDS);
// OOB transport providers are not indexed by addresses, thus each time it creates
@ -354,7 +354,7 @@ public class ManagedChannelImplTransportManagerTest {
assertNotSame(p1, p2);
ClientTransport t2 = p2.get();
verify(mockTransportFactory, timeout(1000).times(2))
.newClientTransport(addr, oobAuthority, userAgent);
.newClientTransport(addr, oobAuthority, USER_AGENT);
assertNotSame(t1, t2);
MockClientTransportInfo transportInfo2 = transports.poll(1, TimeUnit.SECONDS);
assertNotSame(transportInfo1.transport, transportInfo2.transport);

View File

@ -80,7 +80,6 @@ import io.netty.handler.codec.http2.StreamBufferingEncoder;
import io.netty.handler.logging.LogLevel;
import java.nio.channels.ClosedChannelException;
import java.util.Random;
import java.util.concurrent.Executor;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -108,7 +107,6 @@ class NettyClientHandler extends AbstractNettyHandler {
private final Http2Connection.PropertyKey streamKey;
private final ClientTransportLifecycleManager lifecycleManager;
private final Ticker ticker;
private final Random random = new Random();
private WriteQueue clientWriteQueue;
private Http2Ping ping;

View File

@ -566,7 +566,7 @@ public class NettyClientHandlerTest extends NettyHandlerTestBase<NettyClientHand
}
}
class TransportStateImpl extends NettyClientStream.TransportState {
private static class TransportStateImpl extends NettyClientStream.TransportState {
public TransportStateImpl(NettyClientHandler handler, int maxMessageSize) {
super(handler, maxMessageSize);
}

View File

@ -440,7 +440,7 @@ public class NettyClientStreamTest extends NettyStreamTestBase<NettyClientStream
return Utils.convertTrailers(trailers, true);
}
class TransportStateImpl extends NettyClientStream.TransportState {
private static class TransportStateImpl extends NettyClientStream.TransportState {
public TransportStateImpl(NettyClientHandler handler, int maxMessageSize) {
super(handler, maxMessageSize);
}