Index: depends/files/net.properties =================================================================== --- depends/files/net.properties (revision 0) +++ depends/files/net.properties (revision 0) @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Default ProxySelector configuration file. +# + +# General properties names are the following: +# .proxyHost - name of the proxy server for the specified protocol +# .proxyPort - port number to use +# .nonProxyHosts - list of hostnames separated by '|' character +# to be accessed directly (i.e. ignoring +# the proxy server) + +# HTTP proxy settings. +# Default proxy port is equal to 80. +# +# http.proxyHost= +# http.proxyPort=80 +# http.nonProxyHosts=localhost|127.0.0.1 + +# HTTPS proxy settings. +# Default proxy port is equal to 443 +# +# https.proxyHost= +# https.proxyPort=443 + +# FTP proxy settings. +# Default proxy port is equal to 80. +# +# ftp.proxyHost= +# ftp.proxyPort=80 +# ftp.nonProxyHosts=localhost|127.0.0.1 + +# Socks proxy settings. +# Default proxy port is equal to 1080. +# +# socksProxyHost= +# socksProxyPort=1080 Index: make/build-java.xml =================================================================== --- make/build-java.xml (revision 494388) +++ make/build-java.xml (working copy) @@ -254,6 +254,12 @@ + + + + + + Index: modules/luni/src/main/java/java/net/ProxySelectorImpl.java =================================================================== --- modules/luni/src/main/java/java/net/ProxySelectorImpl.java (revision 496614) +++ modules/luni/src/main/java/java/net/ProxySelectorImpl.java (working copy) @@ -15,10 +15,15 @@ */ package java.net; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; import java.io.IOException; import java.security.AccessController; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import org.apache.harmony.luni.util.Msg; import org.apache.harmony.luni.util.PriviAction; @@ -36,6 +41,32 @@ private static final int SOCKS_PROXY_PORT = 1080; + // Net properties read from net.properties file. + private static Properties netProps = null; + + // read net.properties file + static { + AccessController.doPrivileged(new java.security.PrivilegedAction() { + public Object run() { + File f = new File(System.getProperty("java.home") //$NON-NLS-1$ + + File.separator + "lib" + File.separator //$NON-NLS-1$ + + "net.properties"); //$NON-NLS-1$ + + if (f.exists()) { + try { + FileInputStream fis = new FileInputStream(f); + InputStream is = new BufferedInputStream(fis); + netProps = new Properties(); + netProps.load(is); + is.close(); + } catch (IOException e) { + } + } + return null; + } + }); + } + public ProxySelectorImpl() { super(); } @@ -263,11 +294,13 @@ * is null or empty String, it returns defaultValue. */ private String getSystemProperty(final String property, - final String defaultVaule) { + final String defaultValue) { String value = AccessController.doPrivileged(new PriviAction( property)); if (null == value || "".equals(value)) { //$NON-NLS-1$ - value = defaultVaule; + value = (netProps != null) + ? netProps.getProperty(property, defaultValue) + : defaultValue; } return value; }