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

Config: Web Start not detecting proxy properly

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: deploy
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      jre 1.6.0_02 b06

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP SP2

      A DESCRIPTION OF THE PROBLEM :
      Well,

      I tried a code snippet I found and get two radically different answers for proxy hostname/port depending upon if I use Web Start or not.

      If I use Web Start I do not get the correct proxy info. The response seems to be I am making a DIRECT connect to the internet when in fact that is not the case.

      If I create an app directly without using Web Start I get the correct hostname/port.

      The code snippet:

      import java.net.InetSocketAddress;
      import java.net.Proxy;
      import java.net.ProxySelector;
      import java.net.URI;
      import java.net.URL;
      import java.util.Iterator;
      import java.util.List;

      import com.sun.java.browser.net.ProxyInfo;
      import com.sun.java.browser.net.ProxyService;



      public class MainTest {



      /**

      * @param args

      */

      public static void main(String[] args) {

      // TODO Auto-generated method stub

      //detect("http://www.myuniportal.com");

      detect2();



      }



      public static void detect2() {

      try {



      System.setProperty("java.net.useSystemProxies","true");

      List l = ProxySelector.getDefault().select(

      new URI("http://www.yahoo.com/"));



      for (Iterator iter = l.iterator(); iter.hasNext(); ) {



      Proxy proxy = (Proxy) iter.next();



      System.out.println("proxy type : " + proxy.type());



      InetSocketAddress addr = (InetSocketAddress)

      proxy.address();



      if(addr == null) {



      System.out.println("No Proxy");



      } else {



      System.out.println("proxy hostname : " +

      addr.getHostName());



      System.out.println("proxy port : " +

      addr.getPort());



      }

      }

      } catch (Exception e) {

      e.printStackTrace();

      }





      }

      public static void detect(String location)

      {

      String proxyHost;

      int proxyPort;

      try {

      ProxyInfo info[] = ProxyService.getProxyInfo(new URL(location));

      if(info != null && info.length>0)

      {

      proxyHost = info[0].getHost();

      proxyPort = info[0].getPort();

      System.out.println("PROXY = " + proxyHost + ":" + proxyPort);

      }

      }catch (Exception ex) {

      System.err.println(

      "could not retrieve proxy configuration, attempting direct connection." + ex);

      }

      }



      }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Take the test code above and create a jar to run it and download via web start. The output indicates a direct connection to the internet yet it is using a proxy. I need to get the proxy name and port from java when running in the web start environment behind a proxy.

      Thx,
      -Tony


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Well,

      I tried a code snippet I found and get two radically different answers for proxy hostname/port depending upon if I use Web Start or not.

      If I use Web Start I do not get the correct proxy info. The response seems to be I am making a DIRECT connect to the internet when in fact that is not the case.

      If I create an app directly without using Web Start I get the correct hostname/port.

      The code snippet:

      import java.net.InetSocketAddress;
      import java.net.Proxy;
      import java.net.ProxySelector;
      import java.net.URI;
      import java.net.URL;
      import java.util.Iterator;
      import java.util.List;

      import com.sun.java.browser.net.ProxyInfo;
      import com.sun.java.browser.net.ProxyService;



      public class MainTest {



      /**

      * @param args

      */

      public static void main(String[] args) {

      // TODO Auto-generated method stub

      //detect("http://www.myuniportal.com");

      detect2();



      }



      public static void detect2() {

      try {



      System.setProperty("java.net.useSystemProxies","true");

      List l = ProxySelector.getDefault().select(

      new URI("http://www.yahoo.com/"));



      for (Iterator iter = l.iterator(); iter.hasNext(); ) {



      Proxy proxy = (Proxy) iter.next();



      System.out.println("proxy type : " + proxy.type());



      InetSocketAddress addr = (InetSocketAddress)

      proxy.address();



      if(addr == null) {



      System.out.println("No Proxy");



      } else {



      System.out.println("proxy hostname : " +

      addr.getHostName());



      System.out.println("proxy port : " +

      addr.getPort());



      }

      }

      } catch (Exception e) {

      e.printStackTrace();

      }





      }

      public static void detect(String location)

      {

      String proxyHost;

      int proxyPort;

      try {

      ProxyInfo info[] = ProxyService.getProxyInfo(new URL(location));

      if(info != null && info.length>0)

      {

      proxyHost = info[0].getHost();

      proxyPort = info[0].getPort();

      System.out.println("PROXY = " + proxyHost + ":" + proxyPort);

      }

      }catch (Exception ex) {

      System.err.println(

      "could not retrieve proxy configuration, attempting direct connection." + ex);

      }

      }



      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None that I know of.

        Attachments

          Activity

            People

            • Assignee:
              herrick Andy Herrick
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: