You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ay...@apache.org on 2007/03/01 13:45:22 UTC

svn commit: r513297 - in /harmony/enhanced/classlib/trunk: depends/files/net.properties make/build-java.xml modules/luni/src/main/java/java/net/ProxySelectorImpl.java

Author: ayza
Date: Thu Mar  1 04:45:21 2007
New Revision: 513297

URL: http://svn.apache.org/viewvc?view=rev&rev=513297
Log:
Applying patch from HARMONY-2974 ([classlib][luni] jre/lib/net.properties is missing.) 

Added:
    harmony/enhanced/classlib/trunk/depends/files/net.properties   (with props)
Modified:
    harmony/enhanced/classlib/trunk/make/build-java.xml
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java

Added: harmony/enhanced/classlib/trunk/depends/files/net.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/depends/files/net.properties?view=auto&rev=513297
==============================================================================
--- harmony/enhanced/classlib/trunk/depends/files/net.properties (added)
+++ harmony/enhanced/classlib/trunk/depends/files/net.properties Thu Mar  1 04:45:21 2007
@@ -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:
+#     <protocol>.proxyHost - name of the proxy server for the specified protocol
+#     <protocol>.proxyPort - port number to use
+#     <protocol>.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

Propchange: harmony/enhanced/classlib/trunk/depends/files/net.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/make/build-java.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/build-java.xml?view=diff&rev=513297&r1=513296&r2=513297
==============================================================================
--- harmony/enhanced/classlib/trunk/make/build-java.xml (original)
+++ harmony/enhanced/classlib/trunk/make/build-java.xml Thu Mar  1 04:45:21 2007
@@ -258,6 +258,12 @@
                  <include name="java.security" />
              </fileset>
          </copy>
+
+        <copy todir="${hy.jdk}/jre/lib">
+            <fileset dir="${depends.files}">
+                <include name="net.properties" />
+            </fileset>
+        </copy>
     </target>
 
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java?view=diff&rev=513297&r1=513296&r2=513297
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ProxySelectorImpl.java Thu Mar  1 04:45:21 2007
@@ -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<String>(
                 property));
         if (null == value || "".equals(value)) { //$NON-NLS-1$
-            value = defaultVaule;
+            value = (netProps != null)
+                    ? netProps.getProperty(property, defaultValue)
+                    : defaultValue;
         }
         return value;
     }