From 05c416b674d16270ebc02b923e3803d220e99e5b Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Sat, 10 Nov 2012 07:54:33 +0900 Subject: [PATCH] Add 'static' modifier to the methods that don't need to be member methods --- .../multipart/CaseIgnoringComparator.java | 2 +- .../WebSocketServerHandshakerFactory.java | 2 +- .../WebSocketServerProtocolHandlerTest.java | 27 +++++++++---------- .../netty/channel/DefaultChannelPipeline.java | 11 ++++---- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java index bcdcfdd91d..2f571744fc 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/CaseIgnoringComparator.java @@ -32,7 +32,7 @@ public final class CaseIgnoringComparator implements Comparator, Seriali return o1.compareToIgnoreCase(o2); } - @SuppressWarnings("static-method") + @SuppressWarnings("MethodMayBeStatic") private Object readResolve() { return INSTANCE; } diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java index 4e8b48f25d..fe8a0794d8 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketServerHandshakerFactory.java @@ -108,7 +108,7 @@ public class WebSocketServerHandshakerFactory { * @param channel * Channel */ - public void sendUnsupportedWebSocketVersionResponse(Channel channel) { + public static void sendUnsupportedWebSocketVersionResponse(Channel channel) { HttpResponse res = new DefaultHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.SWITCHING_PROTOCOLS); diff --git a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java index 453a90bdf0..d0010a99f7 100644 --- a/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java +++ b/codec-http/src/test/java/io/netty/handler/codec/http/websocketx/WebSocketServerProtocolHandlerTest.java @@ -15,12 +15,6 @@ */ package io.netty.handler.codec.http.websocketx; -import static io.netty.handler.codec.http.HttpHeaders.Values.WEBSOCKET; -import static io.netty.handler.codec.http.HttpResponseStatus.SWITCHING_PROTOCOLS; -import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import io.netty.buffer.MessageBuf; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; @@ -34,10 +28,13 @@ import io.netty.handler.codec.http.HttpRequest; import io.netty.handler.codec.http.HttpRequestDecoder; import io.netty.handler.codec.http.HttpResponse; import io.netty.handler.codec.http.HttpResponseEncoder; -import io.netty.handler.codec.http.HttpResponseStatus; - import org.junit.Test; +import static io.netty.handler.codec.http.HttpHeaders.Values.*; +import static io.netty.handler.codec.http.HttpResponseStatus.*; +import static io.netty.handler.codec.http.HttpVersion.*; +import static org.junit.Assert.*; + public class WebSocketServerProtocolHandlerTest { @Test @@ -76,7 +73,7 @@ public class WebSocketServerProtocolHandlerTest { ch.writeInbound(httpRequest); HttpResponse response = getHttpResponse(ch); - assertEquals(HttpResponseStatus.BAD_REQUEST, response.getStatus()); + assertEquals(BAD_REQUEST, response.getStatus()); assertEquals("not a WebSocket handshake request: missing upgrade", getResponseMessage(response)); } @@ -96,7 +93,7 @@ public class WebSocketServerProtocolHandlerTest { ch.writeInbound(httpRequest); HttpResponse response = getHttpResponse(ch); - assertEquals(HttpResponseStatus.BAD_REQUEST, response.getStatus()); + assertEquals(BAD_REQUEST, response.getStatus()); assertEquals("not a WebSocket request: missing key", getResponseMessage(response)); } @@ -113,11 +110,11 @@ public class WebSocketServerProtocolHandlerTest { assertEquals("processed: payload", customTextFrameHandler.getContent()); } - private EmbeddedMessageChannel createChannel() { + private static EmbeddedMessageChannel createChannel() { return createChannel(null); } - private EmbeddedMessageChannel createChannel(ChannelHandler handler) { + private static EmbeddedMessageChannel createChannel(ChannelHandler handler) { return new EmbeddedMessageChannel( new WebSocketServerProtocolHandler("/test", null, false), new HttpRequestDecoder(), @@ -126,15 +123,15 @@ public class WebSocketServerProtocolHandlerTest { handler); } - private void writeUpgradeRequest(EmbeddedMessageChannel ch) { + private static void writeUpgradeRequest(EmbeddedMessageChannel ch) { ch.writeInbound(WebSocketRequestBuilder.sucessful()); } - private String getResponseMessage(HttpResponse response) { + private static String getResponseMessage(HttpResponse response) { return new String(response.getContent().array()); } - private HttpResponse getHttpResponse(EmbeddedMessageChannel ch) { + private static HttpResponse getHttpResponse(EmbeddedMessageChannel ch) { MessageBuf outbound = ch.pipeline().context(MockOutboundHandler.class).outboundMessageBuffer(); return (HttpResponse) outbound.poll(); } diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java index 73dd39d739..8c0fc883f4 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java @@ -15,7 +15,6 @@ */ package io.netty.channel; -import static io.netty.channel.DefaultChannelHandlerContext.*; import io.netty.buffer.ByteBuf; import io.netty.buffer.ChannelBuf; import io.netty.buffer.MessageBuf; @@ -34,6 +33,8 @@ import java.util.NoSuchElementException; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; +import static io.netty.channel.DefaultChannelHandlerContext.*; + /** * The default {@link ChannelPipeline} implementation. It is usually created * by a {@link Channel} implementation when the {@link Channel} is created. @@ -920,7 +921,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { return nextOutboundByteBuffer(tail); } - boolean hasNextOutboundByteBuffer(DefaultChannelHandlerContext ctx) { + static boolean hasNextOutboundByteBuffer(DefaultChannelHandlerContext ctx) { for (;;) { if (ctx == null) { return false; @@ -933,7 +934,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { } } - boolean hasNextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) { + static boolean hasNextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) { for (;;) { if (ctx == null) { return false; @@ -946,7 +947,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { } } - ByteBuf nextOutboundByteBuffer(DefaultChannelHandlerContext ctx) { + static ByteBuf nextOutboundByteBuffer(DefaultChannelHandlerContext ctx) { final DefaultChannelHandlerContext initialCtx = ctx; final Thread currentThread = Thread.currentThread(); for (;;) { @@ -982,7 +983,7 @@ public class DefaultChannelPipeline implements ChannelPipeline { } } - MessageBuf nextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) { + static MessageBuf nextOutboundMessageBuffer(DefaultChannelHandlerContext ctx) { final DefaultChannelHandlerContext initialCtx = ctx; final Thread currentThread = Thread.currentThread(); for (;;) {