JDK-4442754 : class java.net.URL should have methods to set proxy attributes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-04-12
  • Updated: 2002-08-19
  • Resolved: 2002-08-19
Related Reports
Duplicate :  
Description

Name: boT120536			Date: 04/12/2001


java version "1.3.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_01)
Java HotSpot(TM) Client VM (build 1.3.0_01, mixed mode)

The URL class currently depends on System properties to specify proxy settings,
as follows:

System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "myProxyMachineName" );
System.getProperties().put( "proxyPort", "85" );

However, it is not desirable that these settings be global.  In our
application, we open some URLs without proxy, others with different proxies.
The URL class should allow setting and getting these properties directly, e.g.

boolean URL.getUseProxy()
void URL.setUseProxy(boolean)
(default is System.property; if unspecified, false)

String URL.getProxyHost()
void URL.setProxyHost(String)

integer URL.getProxyPort()
void URL.setProxyPort(integer)

With these additions, it would never be necessary to add properties to the
System property list (unless global default values were desired).

The values in the System property list can still be used as defaults for
backward compatibility.
(Review ID: 120605) 
======================================================================

Comments
WORK AROUND Name: boT120536 Date: 04/12/2001 In a multithreaded environment, to avoid having URL connections accidentally pick up the global properties, it's necessary to synchronize on a global lock, then set the system properties, create the URL, get the URLConnection, open the connection, remove the system properties, and release the lock. This is awkward and definitely not object-oriented. ======================================================================
11-06-2004

EVALUATION Yes, proxy setting should be more flexible. But this is a duplicate of 4696512. ###@###.### 2002-08-19
19-08-2002