Fix some low-hanging code quality issue fruits (#1047)

* Fix some low-hanging code quality issue fruits

These include problems such as: use of raw types, unnecessary throw clauses,
unused variables, and more.
This commit is contained in:
Ben McIlwain
2021-04-01 18:04:21 -04:00
committed by GitHub
parent dc51019fd2
commit 0164bceb95
79 changed files with 163 additions and 196 deletions
@@ -84,7 +84,7 @@ public class ProxyServer implements Runnable {
*/
private static class ServerChannelInitializer extends ChannelInitializer<NioSocketChannel> {
@Override
protected void initChannel(NioSocketChannel inboundChannel) throws Exception {
protected void initChannel(NioSocketChannel inboundChannel) {
// Add inbound channel handlers.
FrontendProtocol inboundProtocol =
(FrontendProtocol) inboundChannel.parent().attr(PROTOCOL_KEY).get();
@@ -110,8 +110,7 @@ public class ProxyServer implements Runnable {
.handler(
new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel outboundChannel)
throws Exception {
protected void initChannel(NioSocketChannel outboundChannel) {
addHandlers(
outboundChannel.pipeline(), outboundProtocol.handlerProviders());
}
@@ -301,7 +300,7 @@ public class ProxyServer implements Runnable {
}
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
// Use JDK logger for Netty's LoggingHandler,
// which is what Flogger uses under the hood.
InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE);
@@ -102,8 +102,7 @@ public class BackendMetricsHandler extends ChannelDuplexHandler {
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
checkArgument(msg instanceof FullHttpRequest, "Outgoing request must be FullHttpRequest.");
// For WHOIS, client certificate hash is always set to "none".
// For EPP, the client hash attribute is set upon handshake completion, before the first HELLO
@@ -88,8 +88,7 @@ public class FrontendMetricsHandler extends ChannelDuplexHandler {
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
// Only instrument request metrics when the response is actually sent to client.
// It is OK to check the queue size preemptively here, not when the front element of the queue
// is acutally removed after the write to the client is successful, because responses are
@@ -33,7 +33,7 @@ public class HealthCheckHandler extends ChannelInboundHandlerAdapter {
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ByteBuf buf = (ByteBuf) msg;
if (buf.equals(checkRequest)) {
ChannelFuture unusedFuture = ctx.writeAndFlush(checkResponse);
@@ -125,8 +125,7 @@ public abstract class HttpsRelayServiceHandler extends ByteToMessageCodec<FullHt
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out)
throws Exception {
protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> out) {
FullHttpRequest request = decodeFullHttpRequest(byteBuf);
loadCookies(request);
out.add(request);
@@ -169,7 +168,7 @@ public abstract class HttpsRelayServiceHandler extends ByteToMessageCodec<FullHt
/** Terminates connection upon inbound exception. */
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
if (NON_FATAL_INBOUND_EXCEPTIONS.contains(Throwables.getRootCause(cause).getClass())) {
logger.atWarning().withCause(cause).log(
"Inbound exception caught for channel %s", ctx.channel());
@@ -133,7 +133,7 @@ public class ProxyProtocolHandler extends ByteToMessageDecoder {
* then removed from the pipeline.
*/
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
// Wait until there are more bytes available than the header's length before processing.
if (in.readableBytes() >= HEADER_PREFIX.length) {
if (containsHeader(in)) {
@@ -62,7 +62,7 @@ public class RelayHandler<I> extends SimpleChannelInboundHandler<I> {
/** Read message of type {@code I}, write it as-is into the relay channel. */
@Override
protected void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception {
protected void channelRead0(ChannelHandlerContext ctx, I msg) {
Channel channel = ctx.channel();
Channel relayChannel = channel.attr(RELAY_CHANNEL_KEY).get();
if (relayChannel == null) {