vaadin / eclipse-plugin

Vaadin Plugin for Eclipse
https://vaadin.com/eclipse
16 stars 8 forks source link

2235: Fix proxy usage for Vaadin 10+ project wizard #802

Closed szolo closed 4 years ago

szolo commented 4 years ago

Relates to https://github.com/vaadin/designer/issues/2235.


This change is Reviewable

szolo commented 4 years ago

I'd like to explain what's happening here.

In Eclipse, system properties are used to control the proxy connections. E.g. I can initialize proxyHost from Java System.getProperties().put("https.proxyHost", host). Or I can pass the property to the JVM -Dhttps.proxyHost=host.

There are different levels where you can define proxy. It could be set per OS, per app or even fetched from some remote resource.

Proxy preference page class (org.eclipse.ui.internal.net.ProxyPreferencePage) resides inside bundle org.eclipse.ui.net. Class org.eclipse.core.internal.net.ProxyType (bundle org.eclipse.core.net) is responsible for system properties setting. E.g. see method org.eclipse.core.internal.net.ProxyType.updateHttpSystemProperties(). System properties are initialized depending on the selected "Active provider". "Manual" means that proxy is set in Eclipse (per app), "Direct" means that there is no proxy and "Native" means that proxy settings are taken from OS.

Eclipse preference page for proxy settings is a bit misleading. E.g. it's possible to edit values for the OS proxy settings ("Native" value of the "Active provider"). But if you would check the code it's clear that values are taken right from the global OS proxy settings, i.e. edited values are ignored. Do not be confused.

I tested and investigated a lot in this area. So question is: why proxy connection doesn't work sometimes, if Eclipse supports this feature?

It seems that connection was failing only for proxies which require authentication (username and password). There is a issue in JDK tracker https://bugs.openjdk.java.net/browse/JDK-8210814/ which says that if you'd like to use basic authentication for HTTPS tunneling you need to set property jdk.http.auth.tunneling.disabledSchemes="". So I just set this property during plugin startup.

I also switched to another API which uses the system properties. It wasn't the case before.

szolo commented 4 years ago

See also https://github.com/vaadin/designer-internal/pull/1717.

tanbt commented 4 years ago

Thanks for the details. I tested it without a proxy, works as usual.

I seefetchStarters and download have repeated codes to open/close http client. Could it be refactor to one method (e.g. using Function), so it can be re-used in the future?