Changeset 6714 in josm for trunk


Ignore:
Timestamp:
2014-01-17T19:06:54+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #7474 - don't use proxy when connecting to localhost

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java

    r6523 r6714  
    2626 */
    2727public class DefaultProxySelector extends ProxySelector {
     28
     29    private static final List<Proxy> NO_PROXY_LIST = Collections.singletonList(Proxy.NO_PROXY);
     30
    2831    /**
    2932     * The {@link ProxySelector} provided by the JDK will retrieve proxy information
     
    184187    @Override
    185188    public List<Proxy> select(URI uri) {
    186         Proxy proxy;
     189        if (uri != null && "localhost".equals(uri.getHost())) {
     190            return NO_PROXY_LIST;
     191        }
    187192        switch(proxyPolicy) {
    188193        case USE_SYSTEM_SETTINGS:
    189194            if (!JVM_WILL_USE_SYSTEM_PROXIES) {
    190195                Main.warn(tr("The JVM is not configured to lookup proxies from the system settings. The property ''java.net.useSystemProxies'' was missing at startup time.  Will not use a proxy."));
    191                 return Collections.singletonList(Proxy.NO_PROXY);
     196                return NO_PROXY_LIST;
    192197            }
    193198            // delegate to the former proxy selector
    194             List<Proxy> ret = delegate.select(uri);
    195             return ret;
     199            return delegate.select(uri);
    196200        case NO_PROXY:
    197             return Collections.singletonList(Proxy.NO_PROXY);
     201            return NO_PROXY_LIST;
    198202        case USE_HTTP_PROXY:
    199203            if (httpProxySocketAddress == null)
    200                 return Collections.singletonList(Proxy.NO_PROXY);
    201             proxy = new Proxy(Type.HTTP, httpProxySocketAddress);
    202             return Collections.singletonList(proxy);
     204                return NO_PROXY_LIST;
     205            return Collections.singletonList(new Proxy(Type.HTTP, httpProxySocketAddress));
    203206        case USE_SOCKS_PROXY:
    204207            if (socksProxySocketAddress == null)
    205                 return Collections.singletonList(Proxy.NO_PROXY);
    206             proxy = new Proxy(Type.SOCKS, socksProxySocketAddress);
    207             return Collections.singletonList(proxy);
     208                return NO_PROXY_LIST;
     209            return Collections.singletonList(new Proxy(Type.SOCKS, socksProxySocketAddress));
    208210        }
    209211        // should not happen
Note: See TracChangeset for help on using the changeset viewer.