Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6948382

Direct socket connection uses http proxy, even no socks proxy is configured

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 6u20
    • core-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP, 32bit, GERMAN, SP3, latest KB installed

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The Windows system settings, for network connections / LAN settings:
      HTTP: 10.77.59.68 port 3128
      HTTPS: 10.77.59.68 port 3128
      FTP: 10.77.59.68 port 3128
      Socks: none!
      Do not use proxy for: 127.0.0.1; loclahost; *.company.intra


      A DESCRIPTION OF THE PROBLEM :
      When using the "java.net.useSystemProxies" property and using java.net.ProxySelector.select(), all following socket connections trying to use
      the HTTP proxy server (while thinking it's a socks server).

      This is totally wrong. And in enterprise environment, where you always
      have a proxy, there should be a useful separation between all the proxies.

      I see similarities with bug ID: 5001942


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test code snippet.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Separate proxy usage for HTTP and socks.
      I see similarities with bug ID: 5001942
      ACTUAL -
      Wrong usage of HTTP proxies for simple and direct socket connections.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.*;
      import java.util.List;

      public class ProxyVsSocket_REPORTED {

      public static void main(String[] args) {
      try {
      System.setProperty("java.net.useSystemProxies", "true");
      final List<Proxy> proxylist = ProxySelector.getDefault().select(
      new URI("http://subdev.company.intra"));
      Proxy proxy = proxylist.get(0);
      System.out.println("Info: proxy: " + proxy.toString() + " - "
      + proxy.address());
      // OUTPUT: proxy: DIRECT - null
      // This is correct.

      // === From now on, ugly things happen:=======

      Socket socket = new Socket();
      InetSocketAddress ep = new InetSocketAddress(Inet4Address
      .getByName("entw.company.intra"), 449);
      socket.connect(ep); // holy crap, this will connect to the proxy!!!
      socket.close();

      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Possible workarounds, which are all bad:
       * Don't use "java.net.useSystemProxies"
       * Remove the default proxy selector by: "ProxySelector.setDefault(null)"

      Both are totally unusable in enterprise environment, where the common
      desktop proxy settings should be used.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: