Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6737819
Votes 0
Synopsis sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
Category java:classes_net
Reported Against
Release Fixed 7(b73), 6u14(b03) (Bug ID:2173399)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 4924226
Submit Date 15-AUG-2008
Description
FULL PRODUCT VERSION :
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux ukp79266 2.6.9-55.0.0.0.2.ELsmp #1 SMP Wed May 2 14:59:56 PDT 2007 i686 i686 i386 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
The DefaultProxySelector implementation will never use a proxy for a request to "localhost" even if the invoker has specifically speficied that no host will be excluded.

This is a problem when trying to connect to a sever on the current machine whilst trying to use some kind of http packet monitoring tool. (In this case the HTTP Analyzer from JDeveloper)

So in this case the url to the web service I am trying to connect with is "http://localhost:7101/..." and the name of the proxy is "localhost:8898". The parameter passed into the running client are:

-Dhttp.proxyHost = localhost
-Dhttp.proxyPort = 8988
-Dhttp.nonProxyHosts =

I would have hoped that the default proxy selector would honor the fact I have requested an empty ingore list. Looking at the code it appears that the test for local host is performed well before the property is even queried.

The localhost test should only be applied if and when the nonProxyHosts property for the given protocol is null.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Configure a http proxying tools such as  customer  mon on the local machine
2. Run web service on machine
3. Run java client for web service with http proxy properties set to use the http proxying tool and set up to connect to a local host URL.

No traffic will be sent the way of the monitor tool. It will never be proxied.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When nonProxyedHosts is defiend as being blank even localhost should be proxied.
ACTUAL -
All request to localhost go un proxied.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Put in place own ProxySelector; but this doesn't allow a developer to test software without making modifications.
Posted Date : 2008-08-15 21:34:24.0
Work Around
When accessing the URL use "http://localhost.localdomain:7101/..." instead of just "http://localhost:7101/..."
Evaluation
As pointed out in the comments, the reason localhost or explicit loopback addresses are excluded from proxying is not quite a bug, it's on purpose.
Asking a proxy to connect to 127.0.0.1 for instance is often seen as a security risk and doesn't make much sense in the general case.
In the case of the DefaultProxySelector it's also a question of backward compatibility. See CR 4924226 for details.

However, we will see if we can use http.nonProxyHosts system property (or another existing one) to change that behavior when set with a special value.
Posted Date : 2008-12-05 15:31:34.0

Actually, we will change the behaviour in JDK 7 as it was introduced by mistake while fixing another bug.
Posted Date : 2009-02-20 13:13:18.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang