Bug 299756 - org.eclipse.core.net is not using/providing a java.net.ProxySelector
Summary: org.eclipse.core.net is not using/providing a java.net.ProxySelector
Status: CLOSED DUPLICATE of bug 257443
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Team (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6   Edit
Assignee: Pawel Pogorzelski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-15 07:36 EST by Ivan Motsch CLA
Modified: 2010-01-18 09:17 EST (History)
2 users (show)

See Also:


Attachments
This is a possible java.net.ProxySelector implementation for eclipse (2.34 KB, text/plain)
2010-01-16 11:28 EST, Ivan Motsch CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Motsch CLA 2010-01-15 07:36:38 EST
Build Identifier: Build id: 20090920-1017

When i use the following code in a "hello world" rcp headless application (no UI and no SWT is used!)...
> BundleContext bc=Activator.getDefault().getBundle().getBundleContext();
> ServiceReference ref=bc.getServiceReference(IProxyService.class.getName());
> IProxyService p=(IProxyService)bc.getService(ref);
> System.out.println(""+p.isSystemProxiesEnabled()+" "+p.isProxiesEnabled());
> URL url=new URL("http://myserver/myapp/servlet");
> System.out.println("Proxy is "+p.select(url.toURI())[0]);
> HttpURLConnection conn=(HttpURLConnection)url.openConnection();
> System.out.println("CODE: "+conn.getResponseCode());
> System.out.println(conn.getInputStream().read());

...this output is generated:
true true
Proxy is localhost:1080
CODE: 404

This shows that IProxyService is correctly detecting that proxy localhost:1080 SHOULD be used, but 
the following line url.openConnection(); obviously connects directly.

when is use instead manually:
> HttpURLConnection conn=(HttpURLConnection)url.openConnection(new java.net.Proxy(...));
then it works.

I know that there is a url.openConnection(IProxy); but since there is a java.net.ProxySelector concept in the jre i expected eclipse.core.net to use/support this.

Questions:
1) why is org.eclipse.core.internal.net.ProxySelector not a java.net.ProxySelector?
2) why is org.eclipse.core.net not automatically installing a java.net.ProxySelector to handle proxy connections? 
3) is it in fact necessary to first call IProxyService.select(...) and then manually calling URL.openConnection(java.net.Proxy) manually?


Reproducible: Always

Steps to Reproduce:
1. I installed a local http proxy on port 1080 and set in the windows internet settings that proxy localhost:1080 should be used for all.
2. I installed a servlet on a server that is only reachable via the proxy, otherwise not.
3. testing in internet explorer with and without proxy showed that the servlet can only be accessed when the proxy is activated in the windows internet settings
Comment 1 Ivan Motsch CLA 2010-01-16 11:28:24 EST
Created attachment 156313 [details]
This is a possible java.net.ProxySelector implementation for eclipse

This attached class could solve this bug.

This is a implementation of a java.net {@link ProxySelector}.
To activate this selector, call {@link ProxySelector#setDefault(ProxySelector)}.

This will enable the full capability of the eclipse proxy selector to the java.net world.
To make a connection, just create an {@link URL} and call {@link URL#openConnection()}.

The {@link ProxySelector} will take care of all proxy related issues automatically.

The application can choose whether or not using automatic proxy selection in java.net.

A custom IApplication my call at bthe beginning:
java.net.ProxySelector.setDefault(new EclipseProxySelector());
Comment 2 Pawel Pogorzelski CLA 2010-01-18 09:00:26 EST
This has to be an optional component since Eclipse SDK has to run on Java 1.4 and ProxySelector was added in 5.0.

ProxySelector based provider is discussed on bug 257443 along with more complex changes to proxy support in Eclipse.
Comment 3 Ivan Motsch CLA 2010-01-18 09:17:35 EST
Thanks.
I will close this one, its a duplicate to Bug 257443
Comment 4 Ivan Motsch CLA 2010-01-18 09:17:58 EST
(In reply to comment #3)
> Thanks.
> I will close this one, its a duplicate to Bug 257443

*** This bug has been marked as a duplicate of bug 257443 ***