mirror of https://github.com/grpc/grpc-java.git
all: ErrorProne fixes and avoid @Beta in Guava
This commit is contained in:
parent
5a4794f2c8
commit
1e99b299e1
|
|
@ -98,9 +98,6 @@ public final class ManagedChannelImpl2 extends ManagedChannel implements WithLog
|
|||
@VisibleForTesting
|
||||
static final long SUBCHANNEL_SHUTDOWN_DELAY_SECONDS = 5;
|
||||
|
||||
private static final ClientTransport SHUTDOWN_TRANSPORT =
|
||||
new FailingClientTransport(Status.UNAVAILABLE.withDescription("Channel is shutdown"));
|
||||
|
||||
@VisibleForTesting
|
||||
static final Status SHUTDOWN_NOW_STATUS =
|
||||
Status.UNAVAILABLE.withDescription("Channel shutdownNow invoked");
|
||||
|
|
@ -631,12 +628,12 @@ public final class ManagedChannelImpl2 extends ManagedChannel implements WithLog
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onInUse(InternalSubchannel is) {
|
||||
void onInUse(InternalSubchannel is) {
|
||||
inUseStateAggregator.updateObjectInUse(is, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotInUse(InternalSubchannel is) {
|
||||
void onNotInUse(InternalSubchannel is) {
|
||||
inUseStateAggregator.updateObjectInUse(is, false);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import java.io.InputStream;
|
|||
* An implementation of {@link ClientStream} that silently does nothing for the operations.
|
||||
*/
|
||||
public class NoopClientStream implements ClientStream {
|
||||
public static NoopClientStream INSTANCE = new NoopClientStream();
|
||||
public static final NoopClientStream INSTANCE = new NoopClientStream();
|
||||
|
||||
@Override
|
||||
public void setAuthority(String authority) {}
|
||||
|
|
|
|||
|
|
@ -168,14 +168,10 @@ public class ManagedChannelImpl2IdlenessTest {
|
|||
|
||||
@Test
|
||||
public void newCallExitsIdleness() throws Exception {
|
||||
final EquivalentAddressGroup addressGroup = addressGroupList.get(1);
|
||||
|
||||
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
|
||||
call.start(mockCallListener, new Metadata());
|
||||
|
||||
ArgumentCaptor<Helper> helperCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(mockLoadBalancerFactory).newLoadBalancer(helperCaptor.capture());
|
||||
Helper helper = helperCaptor.getValue();
|
||||
verify(mockLoadBalancerFactory).newLoadBalancer(any(Helper.class));
|
||||
|
||||
verify(mockNameResolver).start(nameResolverListenerCaptor.capture());
|
||||
// Simulate new address resolved to make sure the LoadBalancer is correctly linked to
|
||||
|
|
@ -186,17 +182,13 @@ public class ManagedChannelImpl2IdlenessTest {
|
|||
|
||||
@Test
|
||||
public void newCallRefreshesIdlenessTimer() throws Exception {
|
||||
final EquivalentAddressGroup addressGroup = addressGroupList.get(1);
|
||||
|
||||
// First call to exit the initial idleness, then immediately cancel the call.
|
||||
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
|
||||
call.start(mockCallListener, new Metadata());
|
||||
call.cancel("For testing", null);
|
||||
|
||||
// Verify that we have exited the idle mode
|
||||
ArgumentCaptor<Helper> helperCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(mockLoadBalancerFactory).newLoadBalancer(helperCaptor.capture());
|
||||
Helper helper = helperCaptor.getValue();
|
||||
verify(mockLoadBalancerFactory).newLoadBalancer(any(Helper.class));
|
||||
assertFalse(channel.inUseStateAggregator.isInUse());
|
||||
|
||||
// Move closer to idleness, but not yet.
|
||||
|
|
@ -297,7 +289,6 @@ public class ManagedChannelImpl2IdlenessTest {
|
|||
|
||||
@Test
|
||||
public void oobTransportDoesNotAffectIdleness() {
|
||||
FakeClock oobExecutor = new FakeClock();
|
||||
// Start a call, which goes to delayed transport
|
||||
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
|
||||
call.start(mockCallListener, new Metadata());
|
||||
|
|
|
|||
|
|
@ -816,8 +816,8 @@ public class ManagedChannelImpl2Test {
|
|||
@Test
|
||||
public void subchannelsNoConnectionShutdownNow() {
|
||||
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
|
||||
Subchannel sub1 = helper.createSubchannel(addressGroup, Attributes.EMPTY);
|
||||
Subchannel sub2 = helper.createSubchannel(addressGroup, Attributes.EMPTY);
|
||||
helper.createSubchannel(addressGroup, Attributes.EMPTY);
|
||||
helper.createSubchannel(addressGroup, Attributes.EMPTY);
|
||||
channel.shutdownNow();
|
||||
|
||||
verify(mockLoadBalancer).shutdown();
|
||||
|
|
@ -975,8 +975,8 @@ public class ManagedChannelImpl2Test {
|
|||
@Test
|
||||
public void oobChannelsNoConnectionShutdownNow() {
|
||||
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
|
||||
ManagedChannel oob1 = helper.createOobChannel(addressGroup, "oob1Authority");
|
||||
ManagedChannel oob2 = helper.createOobChannel(addressGroup, "oob2Authority");
|
||||
helper.createOobChannel(addressGroup, "oob1Authority");
|
||||
helper.createOobChannel(addressGroup, "oob2Authority");
|
||||
channel.shutdownNow();
|
||||
|
||||
verify(mockLoadBalancer).shutdown();
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ import static org.junit.Assert.fail;
|
|||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.timeout;
|
||||
|
||||
import com.google.api.client.repackaged.com.google.common.base.Throwables;
|
||||
import com.google.auth.oauth2.AccessToken;
|
||||
import com.google.auth.oauth2.ComputeEngineCredentials;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
import com.google.auth.oauth2.OAuth2Credentials;
|
||||
import com.google.auth.oauth2.ServiceAccountCredentials;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
|
|
|||
|
|
@ -81,19 +81,19 @@ public class GrpcSslContexts {
|
|||
* These configs use ACCEPT due to limited support in OpenSSL. Actual protocol enforcement is
|
||||
* done in ProtocolNegotiators.
|
||||
*/
|
||||
private static ApplicationProtocolConfig ALPN = new ApplicationProtocolConfig(
|
||||
private static final ApplicationProtocolConfig ALPN = new ApplicationProtocolConfig(
|
||||
Protocol.ALPN,
|
||||
SelectorFailureBehavior.NO_ADVERTISE,
|
||||
SelectedListenerFailureBehavior.ACCEPT,
|
||||
NEXT_PROTOCOL_VERSIONS);
|
||||
|
||||
private static ApplicationProtocolConfig NPN = new ApplicationProtocolConfig(
|
||||
private static final ApplicationProtocolConfig NPN = new ApplicationProtocolConfig(
|
||||
Protocol.NPN,
|
||||
SelectorFailureBehavior.NO_ADVERTISE,
|
||||
SelectedListenerFailureBehavior.ACCEPT,
|
||||
NEXT_PROTOCOL_VERSIONS);
|
||||
|
||||
private static ApplicationProtocolConfig NPN_AND_ALPN = new ApplicationProtocolConfig(
|
||||
private static final ApplicationProtocolConfig NPN_AND_ALPN = new ApplicationProtocolConfig(
|
||||
Protocol.NPN_AND_ALPN,
|
||||
SelectorFailureBehavior.NO_ADVERTISE,
|
||||
SelectedListenerFailureBehavior.ACCEPT,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import static com.google.common.base.Charsets.UTF_8;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.instrumentation.stats.MeasurementDescriptor;
|
||||
import com.google.instrumentation.stats.MeasurementMap;
|
||||
import com.google.instrumentation.stats.MeasurementValue;
|
||||
|
|
@ -44,6 +43,8 @@ import com.google.instrumentation.stats.StatsContextFactory;
|
|||
import com.google.instrumentation.stats.TagKey;
|
||||
import com.google.instrumentation.stats.TagValue;
|
||||
|
||||
import io.grpc.internal.IoUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
|
@ -138,7 +139,7 @@ public class StatsTestUtils {
|
|||
public StatsContext deserialize(InputStream buffer) {
|
||||
String serializedString;
|
||||
try {
|
||||
serializedString = new String(ByteStreams.toByteArray(buffer), UTF_8);
|
||||
serializedString = new String(IoUtils.toByteArray(buffer), UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue