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