diff --git a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java index 42394a248c..a7349e291d 100644 --- a/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java +++ b/connectors/netty-connector/src/main/java/org/glassfish/jersey/netty/connector/NettyConnector.java @@ -193,9 +193,12 @@ protected void initChannel(SocketChannel ch) throws Exception { final String password = ClientProperties.getValue( config.getProperties(), ClientProperties.PROXY_PASSWORD, String.class); - p.addLast(new HttpProxyHandler(new InetSocketAddress(u.getHost(), - u.getPort() == -1 ? 8080 : u.getPort()), - userName, password)); + InetSocketAddress proxyAddress = new InetSocketAddress(u.getHost(), u.getPort() == -1 ? 8080 : u.getPort()); + + HttpProxyHandler httpProxyHandler = ((userName == null) || (password == null)) ? + new HttpProxyHandler(proxyAddress) : + new HttpProxyHandler(proxyAddress, userName, password); + p.addLast(httpProxyHandler); } p.addLast(new HttpClientCodec());