mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 11:38:35 +02:00
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:
parent
891745391f
commit
55ef3279e6
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) {
|
||||
|
|
|
@ -154,7 +154,7 @@ public abstract class ProtocolModuleTest {
|
|||
new EmbeddedChannel(
|
||||
new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
protected void initChannel(Channel ch) throws Exception {
|
||||
protected void initChannel(Channel ch) {
|
||||
initializer.accept(ch);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -81,7 +81,7 @@ class BackendMetricsHandlerTest {
|
|||
new EmbeddedChannel(
|
||||
new ChannelInitializer<EmbeddedChannel>() {
|
||||
@Override
|
||||
protected void initChannel(EmbeddedChannel ch) throws Exception {
|
||||
protected void initChannel(EmbeddedChannel ch) {
|
||||
ch.attr(PROTOCOL_KEY).set(backendProtocol);
|
||||
ch.attr(RELAY_CHANNEL_KEY).set(frontendChannel);
|
||||
ch.pipeline().addLast(handler);
|
||||
|
|
|
@ -82,8 +82,8 @@ class EppServiceHandlerTest {
|
|||
|
||||
private EmbeddedChannel channel;
|
||||
|
||||
private void setHandshakeSuccess(EmbeddedChannel channel, X509Certificate certificate)
|
||||
throws Exception {
|
||||
private void setHandshakeSuccess(EmbeddedChannel channel, X509Certificate certificate) {
|
||||
@SuppressWarnings("unused")
|
||||
Promise<X509Certificate> unusedPromise =
|
||||
channel.attr(CLIENT_CERTIFICATE_PROMISE_KEY).get().setSuccess(certificate);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class EppServiceHandlerTest {
|
|||
setHandshakeSuccess(channel, clientCertificate);
|
||||
}
|
||||
|
||||
private void setHandshakeFailure(EmbeddedChannel channel) throws Exception {
|
||||
private void setHandshakeFailure(EmbeddedChannel channel) {
|
||||
Promise<X509Certificate> unusedPromise =
|
||||
channel
|
||||
.attr(CLIENT_CERTIFICATE_PROMISE_KEY)
|
||||
|
@ -135,12 +135,12 @@ class EppServiceHandlerTest {
|
|||
channel = setUpNewChannel(eppServiceHandler);
|
||||
}
|
||||
|
||||
private EmbeddedChannel setUpNewChannel(EppServiceHandler handler) throws Exception {
|
||||
private EmbeddedChannel setUpNewChannel(EppServiceHandler handler) {
|
||||
return new EmbeddedChannel(
|
||||
DefaultChannelId.newInstance(),
|
||||
new ChannelInitializer<EmbeddedChannel>() {
|
||||
@Override
|
||||
protected void initChannel(EmbeddedChannel ch) throws Exception {
|
||||
protected void initChannel(EmbeddedChannel ch) {
|
||||
ch.attr(REMOTE_ADDRESS_KEY).set(CLIENT_ADDRESS);
|
||||
ch.attr(CLIENT_CERTIFICATE_PROMISE_KEY).set(ch.eventLoop().newPromise());
|
||||
ch.pipeline().addLast(handler);
|
||||
|
|
|
@ -61,7 +61,7 @@ class FrontendMetricsHandlerTest {
|
|||
new EmbeddedChannel(
|
||||
new ChannelInitializer<EmbeddedChannel>() {
|
||||
@Override
|
||||
protected void initChannel(EmbeddedChannel ch) throws Exception {
|
||||
protected void initChannel(EmbeddedChannel ch) {
|
||||
ch.attr(PROTOCOL_KEY).set(frontendProtocol);
|
||||
ch.attr(CLIENT_CERTIFICATE_HASH_KEY).set(CLIENT_CERT_HASH);
|
||||
ch.pipeline().addLast(handler);
|
||||
|
|
|
@ -67,7 +67,7 @@ class QuotaManagerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_rebate() throws Exception {
|
||||
void testSuccess_rebate() {
|
||||
DateTime grantedTokenRefillTime = clock.nowUtc();
|
||||
response = QuotaResponse.create(true, USER_ID, grantedTokenRefillTime);
|
||||
QuotaRebate rebate = QuotaRebate.create(response);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue