Community
Participate
Working Groups
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
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());
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.
Thanks. I will close this one, its a duplicate to Bug 257443
(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 ***