diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java index baef4c6f5e..06d768e5e7 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/websocketx/WebSocketClientHandshakerFactory.java @@ -23,7 +23,13 @@ import static io.netty.handler.codec.http.websocketx.WebSocketVersion.*; /** * Instances the appropriate handshake class to use for clients */ -public class WebSocketClientHandshakerFactory { +public final class WebSocketClientHandshakerFactory { + + /** + * Private constructor so this static class cannot be instanced. + */ + private WebSocketClientHandshakerFactory() { + } /** * Creates a new handshaker. @@ -40,7 +46,7 @@ public class WebSocketClientHandshakerFactory { * @param customHeaders * Custom HTTP headers to send during the handshake */ - public WebSocketClientHandshaker newHandshaker( + public static WebSocketClientHandshaker newHandshaker( URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, Map customHeaders) { return newHandshaker(webSocketURL, version, subprotocol, allowExtensions, customHeaders, 65536); @@ -64,7 +70,7 @@ public class WebSocketClientHandshakerFactory { * Maximum allowable frame payload length. Setting this value to your application's * requirement may reduce denial of service attacks using long data frames. */ - public WebSocketClientHandshaker newHandshaker( + public static WebSocketClientHandshaker newHandshaker( URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, Map customHeaders, int maxFramePayloadLength) { if (version == V13) { diff --git a/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java b/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java index 0454f2a1c2..c7c101f697 100644 --- a/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java +++ b/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java @@ -79,7 +79,7 @@ public class WebSocketClient { // HttpResponseDecoder to WebSocketHttpResponseDecoder in the pipeline. final WebSocketClientHandler handler = new WebSocketClientHandler( - new WebSocketClientHandshakerFactory().newHandshaker( + WebSocketClientHandshakerFactory.newHandshaker( uri, WebSocketVersion.V13, null, false, customHeaders)); b.group(new NioEventLoopGroup())