workaround network properties inconsistencies under Java Web Start





9
Date Submitted Thu. May. 18th, 2006 2:02 AM
Revision 3 of 3
Helper jbuchberger
Tags Java
Comments 0 comments
With Java Web Start 1.5.0 all of a sudden new proxy properties were introduced (deployment.proxy.http.host, deployment.proxy.http.port and deployment.proxy.bypass.list) valid only for the webstart environment - and if that was not enough yet, it does not support the existing proxy properties, neither the standard, nor the deprecated ones from old Java releases. To topple even that, for the bypass-list the delimiters were changed to semicolon (http.nonProxyHosts has the pipe char as delimiter) ...

standard networking properties

the workaround here makes sure, that if any one of these proxy properties (deprecated, standard or webstart-5 ones) are set, that all the others get the same settings - this pays off, if you're using different third-party components relying on one specific set of these proxy properties (especially if it's beyond your power, in what kind of environment the software will be executed respectively integrated...)


        String proxyHost = System.getProperty("proxyHost");
        String proxyPort = System.getProperty("proxyPort");
        String nonProxyHosts = System.getProperty("nonProxyHosts");
           
        if (proxyHost != null)
        {
            // set standard proxy property
            System.setProperty("http.proxyHost", proxyHost);
        }
        else if ((proxyHost = System.getProperty("http.proxyHost")) != null)
        {
            // standard proxy property is set -> just in case some software expects it,
            // use it also for deprecated proxy property
            System.setProperty("proxyHost", proxyHost);
        }
        else if ((proxyHost = System.getProperty("deployment.proxy.http.host")) != null)
        {
            // javaws proxy property is set ->
            // use it also for standard and deprecated proxy property
            System.setProperty("proxyHost", proxyHost);
            System.setProperty("http.proxyHost", proxyHost);
        }
   
        if (proxyPort != null)
        {
            // set standard proxy property
            System.setProperty("http.proxyPort", proxyPort);
        }
        else if ((proxyPort = System.getProperty("http.proxyPort")) != null)
        {
            // standard proxy property is set -> just in case some software expects it,
            // use it also for deprecated proxy property
            System.setProperty("proxyPort", proxyPort);
        }
        else if ((proxyPort = System.getProperty("deployment.proxy.http.port")) != null)
        {
            System.setProperty("proxyPort", proxyPort);
            System.setProperty("http.proxyPort", proxyPort);
        }

        // set nonproxy hosts (deprecated and standard property)
        if (nonProxyHosts == null) nonProxyHosts =
                System.getProperty("http.nonProxyHosts");
        String proxyBypassList = System.getProperty("deployment.proxy.bypass.list");
        if (nonProxyHosts == null && proxyBypassList != null)
        {
            nonProxyHosts = proxyBypassList.replace(';', '|');
        }
       
        nonProxyHosts = updateNonProxyHosts(isProxyEnabled(), nonProxyHosts);
        if (nonProxyHosts != null)
        {
            System.setProperty("nonProxyHosts", nonProxyHosts);
            System.setProperty("http.nonProxyHosts", nonProxyHosts);
            proxyBypassList = nonProxyHosts.replace('|', ';');
            System.setProperty("deployment.proxy.bypass.list", proxyBypassList);
        }

 

Joerg Buchberger

Comments

There are currently no comments for this snippet.

Voting