Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-10-07 13:43:41 -0400
committerThomas Wolf2019-10-07 13:43:41 -0400
commit909896cf1a7657ac721045f673983eed57664643 (patch)
tree0986f7eff8e1f5d0cc2852405e1b9a18bbf3abd1
parent34a18ec423eeebeca5b84eb84e752d8b19e0111f (diff)
downloadegit-909896cf1a7657ac721045f673983eed57664643.tar.gz
egit-909896cf1a7657ac721045f673983eed57664643.tar.xz
egit-909896cf1a7657ac721045f673983eed57664643.zip
Use Apache HTTP by default
Add a preference with UI to choose between the JDK built-in HTTP handling and Apache HTTP. Set the default to Apache HTTP. In case of trouble the user can switch back to using the Java standard HTTP client. The advantage of the Apache HTTP client is that it allows using Basic authentication when HTTPS connections are to be made over an HTTP proxy. OpenJDK forbids that by default since Java 8u111,[1] and changing the JDK configuration to re-allow it is not obvious at all and cannot be done automatically from within Eclipse. [1] https://bugs.openjdk.java.net/browse/JDK-8210814 Bug: 549832 Change-Id: I71928b627d3af4dae95bdab63e019c75ab7e6a9e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit-feature/feature.xml1
-rw-r--r--org.eclipse.egit.core/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java39
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferenceInitializer.java1
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferences.java10
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java3
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java9
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java19
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties3
10 files changed, 81 insertions, 7 deletions
diff --git a/org.eclipse.egit-feature/feature.xml b/org.eclipse.egit-feature/feature.xml
index dea32fb9a..5f0690c24 100644
--- a/org.eclipse.egit-feature/feature.xml
+++ b/org.eclipse.egit-feature/feature.xml
@@ -42,6 +42,7 @@
<import plugin="com.jcraft.jsch" version="0.1.55" match="compatible"/>
<import feature="org.eclipse.jgit" version="5.6.0" match="equivalent"/>
<import feature="org.eclipse.jgit.ssh.apache" version="5.6.0" match="equivalent"/>
+ <import feature="org.eclipse.jgit.http.apache" version="5.6.0" match="equivalent"/>
</requires>
<plugin
diff --git a/org.eclipse.egit.core/META-INF/MANIFEST.MF b/org.eclipse.egit.core/META-INF/MANIFEST.MF
index 3d74a2f6c..5e6cbbbd7 100644
--- a/org.eclipse.egit.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.core/META-INF/MANIFEST.MF
@@ -76,6 +76,8 @@ Import-Package: com.jcraft.jsch;bundle-version="[0.1.53,0.2.0)",
org.eclipse.jgit.storage.file;version="[5.6.0,5.7.0)",
org.eclipse.jgit.submodule;version="[5.6.0,5.7.0)",
org.eclipse.jgit.transport;version="[5.6.0,5.7.0)",
+ org.eclipse.jgit.transport.http;version="[5.6.0,5.7.0)",
+ org.eclipse.jgit.transport.http.apache;version="[5.6.0,5.7.0)",
org.eclipse.jgit.transport.sshd;version="[5.6.0,5.7.0)",
org.eclipse.jgit.treewalk;version="[5.6.0,5.7.0)",
org.eclipse.jgit.treewalk.filter;version="[5.6.0,5.7.0)",
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
index 6805c4795..66238957b 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
@@ -75,7 +75,10 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.merge.MergeStrategy;
import org.eclipse.jgit.storage.file.FileBasedConfig;
+import org.eclipse.jgit.transport.HttpTransport;
import org.eclipse.jgit.transport.SshSessionFactory;
+import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory;
+import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory;
import org.eclipse.jgit.transport.sshd.SshdSessionFactory;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.SystemReader;
@@ -98,6 +101,10 @@ public class Activator extends Plugin implements DebugOptionsListener {
JSCH, APACHE
}
+ private enum HttpClientType {
+ JDK, APACHE
+ }
+
private static Activator plugin;
private static String pluginId;
private RepositoryCache repositoryCache;
@@ -108,7 +115,7 @@ public class Activator extends Plugin implements DebugOptionsListener {
private IResourceChangeListener preDeleteProjectListener;
private IgnoreDerivedResources ignoreDerivedResourcesListener;
private MergeStrategyRegistryListener mergeStrategyRegistryListener;
- private IPreferenceChangeListener sshClientChangeListener;
+ private IPreferenceChangeListener preferenceChangeListener;
private ServiceTracker<IProxyService, IProxyService> proxyServiceTracker;
/**
@@ -225,18 +232,22 @@ public class Activator extends Plugin implements DebugOptionsListener {
context.registerService(DebugOptionsListener.class.getName(), this,
props);
+ setupHttp();
SshPreferencesMirror.INSTANCE.start();
proxyServiceTracker = new ServiceTracker<>(context,
IProxyService.class.getName(), null);
proxyServiceTracker.open();
setupSSH(context);
- sshClientChangeListener = event -> {
+ preferenceChangeListener = event -> {
if (GitCorePreferences.core_sshClient.equals(event.getKey())) {
setupSSH(getBundle().getBundleContext());
+ } else if (GitCorePreferences.core_httpClient
+ .equals(event.getKey())) {
+ setupHttp();
}
};
InstanceScope.INSTANCE.getNode(pluginId)
- .addPreferenceChangeListener(sshClientChangeListener);
+ .addPreferenceChangeListener(preferenceChangeListener);
setupProxy();
repositoryCache = new RepositoryCache();
@@ -298,6 +309,22 @@ public class Activator extends Plugin implements DebugOptionsListener {
}
}
+ private void setupHttp() {
+ String sshClient = Platform.getPreferencesService().getString(pluginId,
+ GitCorePreferences.core_httpClient, "jdk", null); //$NON-NLS-1$
+ if (HttpClientType.APACHE.name().equalsIgnoreCase(sshClient)) {
+ HttpTransport.setConnectionFactory(new HttpClientConnectionFactory());
+ } else {
+ if (!HttpClientType.JDK.name().equalsIgnoreCase(sshClient)) {
+ logWarning(
+ MessageFormat.format(
+ CoreText.Activator_HttpClientUnknown, sshClient),
+ null);
+ }
+ HttpTransport.setConnectionFactory(new JDKHttpConnectionFactory());
+ }
+ }
+
private void setupProxy() {
IProxyService proxy = getProxyService();
if (proxy != null) {
@@ -464,10 +491,10 @@ public class Activator extends Plugin implements DebugOptionsListener {
@Override
public void stop(final BundleContext context) throws Exception {
SshPreferencesMirror.INSTANCE.stop();
- if (sshClientChangeListener != null) {
+ if (preferenceChangeListener != null) {
InstanceScope.INSTANCE.getNode(pluginId)
- .removePreferenceChangeListener(sshClientChangeListener);
- sshClientChangeListener = null;
+ .removePreferenceChangeListener(preferenceChangeListener);
+ preferenceChangeListener = null;
}
SshSessionFactory current = SshSessionFactory.getInstance();
if (current instanceof SshdSessionFactory) {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferenceInitializer.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferenceInitializer.java
index 49d71322d..5d0c6e7c1 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferenceInitializer.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferenceInitializer.java
@@ -38,6 +38,7 @@ public class GitCorePreferenceInitializer extends AbstractPreferenceInitializer
p.put(GitCorePreferences.core_defaultRepositoryDir, defaultRepoDir);
p.putInt(GitCorePreferences.core_maxPullThreadsCount, 1);
p.put(GitCorePreferences.core_sshClient, "apache"); //$NON-NLS-1$
+ p.put(GitCorePreferences.core_httpClient, "apache"); //$NON-NLS-1$
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferences.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferences.java
index 43ab5ad35..d4c164f9d 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferences.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/GitCorePreferences.java
@@ -81,9 +81,17 @@ public final class GitCorePreferences {
public static final String core_maxPullThreadsCount = "core_max_pull_threads_count"; //$NON-NLS-1$
/**
+ * HTTP client library to use. Currently allowed values are "jdk" and
+ * "apache", case insensitive, if undefined or any other value the default
+ * "jdk" will be used.
+ */
+ public static final String core_httpClient = "core_http_client"; //$NON-NLS-1$
+
+ /**
* Ssh client library to use. Currently allowed values are "jsch" and
* "apache", case insensitive, if undefined or any other value the default
- * "jsch" will be used.
+ * "apache" will be used.
*/
public static final String core_sshClient = "core_ssh_client"; //$NON-NLS-1$
+
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java
index 581485b66..ef01832a3 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/CoreText.java
@@ -43,6 +43,9 @@ public class CoreText extends NLS {
public static String Activator_AutoSharingFailed;
/** */
+ public static String Activator_HttpClientUnknown;
+
+ /** */
public static String Activator_ignoreResourceFailed;
/** */
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties
index a3bf98dc9..9ef9af42d 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/coretext.properties
@@ -46,6 +46,7 @@ DisconnectProviderOperation_disconnecting=Disconnecting Git team provider.
Activator_autoIgnoreDerivedResources=Auto-ignore derived resources
Activator_AutoShareJobName=Auto share git projects
Activator_AutoSharingFailed=Auto sharing project with git failed
+Activator_HttpClientUnknown=Unknown HTTP library ''{0}'' configured; valid values are "jdk" or "apache". Using JDK.
Activator_ignoreResourceFailed=Ignoring {0} failed
Activator_noBuiltinLfsSupportDetected=Built-in LFS support not present/detected
Activator_ReconfigureWindowCacheError=Exception when reconfiguring window cache from configuration, default configuration will be used
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index 394df7030..a37cc913c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -694,6 +694,12 @@ public class UIText extends NLS {
public static String GitPreferenceRoot_DefaultRepoFolderVariableButton;
/** */
+ public static String GitPreferenceRoot_HttpClient_Jdk_Label;
+
+ /** */
+ public static String GitPreferenceRoot_HttpClient_Apache_Label;
+
+ /** */
public static String GitPreferenceRoot_MergeGroupHeader;
/** */
@@ -4892,6 +4898,9 @@ public class UIText extends NLS {
public static String GitPreferenceRoot_MaxPullThreadsCountTooltip;
/** */
+ public static String RemoteConnectionPreferencePage_HttpClientLabel;
+
+ /** */
public static String RemoteConnectionPreferencePage_SshClientLabel;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java
index 3e6b63363..61d9c7704 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/GitPreferenceRoot.java
@@ -56,6 +56,8 @@ public class GitPreferenceRoot extends DoublePreferencesPreferencePage
private final static String[][] SSH_CLIENT_NAMES_AND_VALUES = new String[2][2];
+ private final static String[][] HTTP_CLIENT_NAMES_AND_VALUES = new String[2][2];
+
private final static boolean HAS_DEBUG_UI = hasDebugUiBundle();
static {
@@ -70,6 +72,11 @@ public class GitPreferenceRoot extends DoublePreferencesPreferencePage
SSH_CLIENT_NAMES_AND_VALUES[0][1] = "jsch"; //$NON-NLS-1$
SSH_CLIENT_NAMES_AND_VALUES[1][0] = UIText.GitPreferenceRoot_SshClient_Apache_Label;
SSH_CLIENT_NAMES_AND_VALUES[1][1] = "apache"; //$NON-NLS-1$
+
+ HTTP_CLIENT_NAMES_AND_VALUES[0][0] = UIText.GitPreferenceRoot_HttpClient_Jdk_Label;
+ HTTP_CLIENT_NAMES_AND_VALUES[0][1] = "jdk"; //$NON-NLS-1$
+ HTTP_CLIENT_NAMES_AND_VALUES[1][0] = UIText.GitPreferenceRoot_HttpClient_Apache_Label;
+ HTTP_CLIENT_NAMES_AND_VALUES[1][1] = "apache"; //$NON-NLS-1$
}
/**
@@ -225,6 +232,18 @@ public class GitPreferenceRoot extends DoublePreferencesPreferencePage
};
addField(sshClient);
+ ComboFieldEditor httpClient = new ComboFieldEditor(
+ GitCorePreferences.core_httpClient,
+ UIText.RemoteConnectionPreferencePage_HttpClientLabel,
+ HTTP_CLIENT_NAMES_AND_VALUES, remoteConnectionsGroup) {
+
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return getSecondaryPreferenceStore();
+ }
+
+ };
+ addField(httpClient);
updateMargins(remoteConnectionsGroup);
Group repoChangeScannerGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index dbc7ada86..e06b885aa 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -250,6 +250,8 @@ GitPreferenceRoot_CloningRepoGroupHeader=Cloning repositories
GitPreferenceRoot_DefaultRepoFolderLabel=Default repository &folder:
GitPreferenceRoot_DefaultRepoFolderTooltip=This folder will be suggested as parent folder when cloning a remote repository
GitPreferenceRoot_DefaultRepoFolderVariableButton=&Variable...
+GitPreferenceRoot_HttpClient_Jdk_Label=Java built-in HTTP
+GitPreferenceRoot_HttpClient_Apache_Label=Apache HTTP
GitPreferenceRoot_MergeGroupHeader=Merge
GitPreferenceRoot_MergeMode_0_Label=Prompt when starting tool
GitPreferenceRoot_MergeMode_1_Label=Workspace (pre-merged by Git)
@@ -1765,6 +1767,7 @@ NotesEditorPage_Title=Notes
GitPreferenceRoot_MaxPullThreadsCount=&Maximum number of parallel pulls:
GitPreferenceRoot_MaxPullThreadsCountTooltip=1 disables parallel pulls
+RemoteConnectionPreferencePage_HttpClientLabel=&HTTP client:
RemoteConnectionPreferencePage_SshClientLabel=&SSH client:
RemoteConnectionPreferencePage_TimeoutLabel=&Connection timeout (seconds):
RemoteConnectionPreferencePage_ZeroValueTooltip=0 is equivalent to no timeout

Back to the top