JDK-7178362 : Socket impls should ignore unsupported proxy types rather than throwing
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6u30
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-06-20
  • Updated: 2016-05-27
  • Resolved: 2015-02-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
7u80Fixed 8u45Fixed 9 b53Fixed
Related Reports
Duplicate :  
In the case of a "bad" ProxySelector returning proxies of types other than Proxy.Type.SOCKS to the socket impl ( java.net.SocksSocketImpl ) we should just ignore these proxies and try a direct connection, rather than throwing SocketException("Unknown proxy type : XXXX"). This is a confusing Exception and message, and a better alternative is to simply try a direct connection.

Exception in thread "main" java.net.SocketException: Unknown proxy type : HTTP
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:395)
        at java.net.Socket.connect(Socket.java:578)
        at java.net.Socket.connect(Socket.java:527)
        at java.net.Socket.<init>(Socket.java:423)
        at java.net.Socket.<init>(Socket.java:240)

This issue has been reported on several forums and sites:

Minimal testcase to demonstrate the problem:
public class BadProxySelector {
    public static void main(String[] args) throws Exception {
        ProxySelector oldSelector = ProxySelector.getDefault();
        ProxySelector.setDefault(new HTTPProxySelector());
        try {
            try (ServerSocket ss = new ServerSocket(0);
                 Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort());
                 Socket s2 = ss.accept()) {
        } finally {

    // always returns bogus HTTP proxies
    private static class HTTPProxySelector extends ProxySelector {
        public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {}

        public List<Proxy> select(URI uri) {
            List<Proxy> proxies = new ArrayList<>();
            proxies.add(new Proxy(Proxy.Type.HTTP,
                                  new InetSocketAddress("localhost", 56789)));
            proxies.add(new Proxy(Proxy.Type.HTTP,
                                  new InetSocketAddress("localhost", 56784)));
            return proxies;

SQE OK to take the fix to PSU15_02 based on 7u85 nightly testing

This is currently a P4 and does not appear to be critical for JDK 8. I'm temporarily setting the fixVersion to tbd_major until there is a definite plan for this one.

EVALUATION This is a confusing Exception and message, and a better alternative is to try a direct connection.