Skip to content

Commit 1e99b29

Browse files
authored
all: ErrorProne fixes and avoid @beta in Guava
1 parent 5a4794f commit 1e99b29

File tree

7 files changed

+16
-27
lines changed

7 files changed

+16
-27
lines changed

core/src/main/java/io/grpc/internal/ManagedChannelImpl2.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ public final class ManagedChannelImpl2 extends ManagedChannel implements WithLog
9898
@VisibleForTesting
9999
static final long SUBCHANNEL_SHUTDOWN_DELAY_SECONDS = 5;
100100

101-
private static final ClientTransport SHUTDOWN_TRANSPORT =
102-
new FailingClientTransport(Status.UNAVAILABLE.withDescription("Channel is shutdown"));
103-
104101
@VisibleForTesting
105102
static final Status SHUTDOWN_NOW_STATUS =
106103
Status.UNAVAILABLE.withDescription("Channel shutdownNow invoked");
@@ -631,12 +628,12 @@ void onStateChange(InternalSubchannel is, ConnectivityStateInfo newState) {
631628
}
632629

633630
@Override
634-
public void onInUse(InternalSubchannel is) {
631+
void onInUse(InternalSubchannel is) {
635632
inUseStateAggregator.updateObjectInUse(is, true);
636633
}
637634

638635
@Override
639-
public void onNotInUse(InternalSubchannel is) {
636+
void onNotInUse(InternalSubchannel is) {
640637
inUseStateAggregator.updateObjectInUse(is, false);
641638
}
642639
});

core/src/main/java/io/grpc/internal/NoopClientStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* An implementation of {@link ClientStream} that silently does nothing for the operations.
4343
*/
4444
public class NoopClientStream implements ClientStream {
45-
public static NoopClientStream INSTANCE = new NoopClientStream();
45+
public static final NoopClientStream INSTANCE = new NoopClientStream();
4646

4747
@Override
4848
public void setAuthority(String authority) {}

core/src/test/java/io/grpc/internal/ManagedChannelImpl2IdlenessTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,10 @@ public void allPendingTasksAreRun() {
168168

169169
@Test
170170
public void newCallExitsIdleness() throws Exception {
171-
final EquivalentAddressGroup addressGroup = addressGroupList.get(1);
172-
173171
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
174172
call.start(mockCallListener, new Metadata());
175173

176-
ArgumentCaptor<Helper> helperCaptor = ArgumentCaptor.forClass(null);
177-
verify(mockLoadBalancerFactory).newLoadBalancer(helperCaptor.capture());
178-
Helper helper = helperCaptor.getValue();
174+
verify(mockLoadBalancerFactory).newLoadBalancer(any(Helper.class));
179175

180176
verify(mockNameResolver).start(nameResolverListenerCaptor.capture());
181177
// Simulate new address resolved to make sure the LoadBalancer is correctly linked to
@@ -186,17 +182,13 @@ public void newCallExitsIdleness() throws Exception {
186182

187183
@Test
188184
public void newCallRefreshesIdlenessTimer() throws Exception {
189-
final EquivalentAddressGroup addressGroup = addressGroupList.get(1);
190-
191185
// First call to exit the initial idleness, then immediately cancel the call.
192186
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
193187
call.start(mockCallListener, new Metadata());
194188
call.cancel("For testing", null);
195189

196190
// Verify that we have exited the idle mode
197-
ArgumentCaptor<Helper> helperCaptor = ArgumentCaptor.forClass(null);
198-
verify(mockLoadBalancerFactory).newLoadBalancer(helperCaptor.capture());
199-
Helper helper = helperCaptor.getValue();
191+
verify(mockLoadBalancerFactory).newLoadBalancer(any(Helper.class));
200192
assertFalse(channel.inUseStateAggregator.isInUse());
201193

202194
// Move closer to idleness, but not yet.
@@ -297,7 +289,6 @@ public void realTransportsHoldsOffIdleness() throws Exception {
297289

298290
@Test
299291
public void oobTransportDoesNotAffectIdleness() {
300-
FakeClock oobExecutor = new FakeClock();
301292
// Start a call, which goes to delayed transport
302293
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
303294
call.start(mockCallListener, new Metadata());

core/src/test/java/io/grpc/internal/ManagedChannelImpl2Test.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,8 @@ public void subchannelsNoConnectionShutdown() {
816816
@Test
817817
public void subchannelsNoConnectionShutdownNow() {
818818
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
819-
Subchannel sub1 = helper.createSubchannel(addressGroup, Attributes.EMPTY);
820-
Subchannel sub2 = helper.createSubchannel(addressGroup, Attributes.EMPTY);
819+
helper.createSubchannel(addressGroup, Attributes.EMPTY);
820+
helper.createSubchannel(addressGroup, Attributes.EMPTY);
821821
channel.shutdownNow();
822822

823823
verify(mockLoadBalancer).shutdown();
@@ -975,8 +975,8 @@ public void oobChannelsNoConnectionShutdown() {
975975
@Test
976976
public void oobChannelsNoConnectionShutdownNow() {
977977
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
978-
ManagedChannel oob1 = helper.createOobChannel(addressGroup, "oob1Authority");
979-
ManagedChannel oob2 = helper.createOobChannel(addressGroup, "oob2Authority");
978+
helper.createOobChannel(addressGroup, "oob1Authority");
979+
helper.createOobChannel(addressGroup, "oob2Authority");
980980
channel.shutdownNow();
981981

982982
verify(mockLoadBalancer).shutdown();

interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
import static org.mockito.Mockito.mock;
4343
import static org.mockito.Mockito.timeout;
4444

45-
import com.google.api.client.repackaged.com.google.common.base.Throwables;
4645
import com.google.auth.oauth2.AccessToken;
4746
import com.google.auth.oauth2.ComputeEngineCredentials;
4847
import com.google.auth.oauth2.GoogleCredentials;
4948
import com.google.auth.oauth2.OAuth2Credentials;
5049
import com.google.auth.oauth2.ServiceAccountCredentials;
5150
import com.google.common.annotations.VisibleForTesting;
51+
import com.google.common.base.Throwables;
5252
import com.google.common.collect.ImmutableList;
5353
import com.google.common.collect.Lists;
5454
import com.google.common.net.HostAndPort;

netty/src/main/java/io/grpc/netty/GrpcSslContexts.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,19 @@ private GrpcSslContexts() {}
8181
* These configs use ACCEPT due to limited support in OpenSSL. Actual protocol enforcement is
8282
* done in ProtocolNegotiators.
8383
*/
84-
private static ApplicationProtocolConfig ALPN = new ApplicationProtocolConfig(
84+
private static final ApplicationProtocolConfig ALPN = new ApplicationProtocolConfig(
8585
Protocol.ALPN,
8686
SelectorFailureBehavior.NO_ADVERTISE,
8787
SelectedListenerFailureBehavior.ACCEPT,
8888
NEXT_PROTOCOL_VERSIONS);
8989

90-
private static ApplicationProtocolConfig NPN = new ApplicationProtocolConfig(
90+
private static final ApplicationProtocolConfig NPN = new ApplicationProtocolConfig(
9191
Protocol.NPN,
9292
SelectorFailureBehavior.NO_ADVERTISE,
9393
SelectedListenerFailureBehavior.ACCEPT,
9494
NEXT_PROTOCOL_VERSIONS);
9595

96-
private static ApplicationProtocolConfig NPN_AND_ALPN = new ApplicationProtocolConfig(
96+
private static final ApplicationProtocolConfig NPN_AND_ALPN = new ApplicationProtocolConfig(
9797
Protocol.NPN_AND_ALPN,
9898
SelectorFailureBehavior.NO_ADVERTISE,
9999
SelectedListenerFailureBehavior.ACCEPT,

testing/src/main/java/io/grpc/internal/testing/StatsTestUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import static com.google.common.base.Preconditions.checkNotNull;
3636

3737
import com.google.common.collect.ImmutableMap;
38-
import com.google.common.io.ByteStreams;
3938
import com.google.instrumentation.stats.MeasurementDescriptor;
4039
import com.google.instrumentation.stats.MeasurementMap;
4140
import com.google.instrumentation.stats.MeasurementValue;
@@ -44,6 +43,8 @@
4443
import com.google.instrumentation.stats.TagKey;
4544
import com.google.instrumentation.stats.TagValue;
4645

46+
import io.grpc.internal.IoUtils;
47+
4748
import java.io.IOException;
4849
import java.io.InputStream;
4950
import java.io.OutputStream;
@@ -138,7 +139,7 @@ public MetricsRecord pollRecord(long timeout, TimeUnit unit) throws InterruptedE
138139
public StatsContext deserialize(InputStream buffer) {
139140
String serializedString;
140141
try {
141-
serializedString = new String(ByteStreams.toByteArray(buffer), UTF_8);
142+
serializedString = new String(IoUtils.toByteArray(buffer), UTF_8);
142143
} catch (IOException e) {
143144
throw new RuntimeException(e);
144145
}

0 commit comments

Comments
 (0)