Enable new errorprone checks and fix violations (#3018)

This commit is contained in:
Weimin Yu
2026-04-20 21:03:36 +00:00
committed by GitHub
parent 9d5650132b
commit 3de790fb00
98 changed files with 406 additions and 444 deletions
@@ -114,8 +114,8 @@ public class ProxyProtocolHandler extends ByteToMessageDecoder {
private static String getSourceIP(ChannelHandlerContext ctx) {
SocketAddress remoteAddress = ctx.channel().remoteAddress();
return (remoteAddress instanceof InetSocketAddress)
? ((InetSocketAddress) remoteAddress).getAddress().getHostAddress()
return (remoteAddress instanceof InetSocketAddress inetSocketAddress)
? inetSocketAddress.getAddress().getHostAddress()
: null;
}
@@ -93,8 +93,8 @@ public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
// to zero and its buffer will be freed. After the buffer is freed, the message cannot be used
// anymore, even if in Java's eye the object still exist, its content is gone. We increment a
// count here so that the message can be retried, in case the relay is not successful.
if (msg instanceof ReferenceCounted) {
((ReferenceCounted) msg).retain();
if (msg instanceof ReferenceCounted referenceCounted) {
referenceCounted.retain();
}
ChannelFuture unusedFuture =
relayChannel
@@ -150,8 +150,8 @@ public final class TestUtils {
private static void assertHttpMessageEquivalent(HttpMessage msg1, HttpMessage msg2) {
assertThat(msg1.protocolVersion()).isEqualTo(msg2.protocolVersion());
assertThat(msg1.headers()).isEqualTo(msg2.headers());
if (msg1 instanceof FullHttpRequest && msg2 instanceof FullHttpRequest) {
assertThat(((FullHttpRequest) msg1).content()).isEqualTo(((FullHttpRequest) msg2).content());
if (msg1 instanceof FullHttpRequest req1 && msg2 instanceof FullHttpRequest req2) {
assertThat(req1.content()).isEqualTo(req2.content());
}
}
@@ -302,8 +302,7 @@ class TokenStoreTest {
// Verify that a task is scheduled.
ArgumentCaptor<Runnable> argument = ArgumentCaptor.forClass(Runnable.class);
verify(refreshExecutor)
.scheduleWithFixedDelay(
argument.capture(), eq((long) 5), eq((long) 5), eq(TimeUnit.SECONDS));
.scheduleWithFixedDelay(argument.capture(), eq(5L), eq(5L), eq(TimeUnit.SECONDS));
// Verify that the scheduled task calls TokenStore.refresh().
argument.getValue().run();