aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Michel2010-10-21 09:46:04 (EDT)
committerMatthias Sohn2010-10-21 09:46:04 (EDT)
commitc0636b5c957ae520799f9b073da16f5455ad539e (patch)
tree661985a17ae0200a0b61d3baf2a60a664993bd97
parentd2d3e078d3f18e35ecf4bcf077e039fc207af488 (diff)
downloadegit-c0636b5c957ae520799f9b073da16f5455ad539e.zip
egit-c0636b5c957ae520799f9b073da16f5455ad539e.tar.gz
egit-c0636b5c957ae520799f9b073da16f5455ad539e.tar.bz2
Fix potential NPE in EclipseProxySelectorrefs/changes/78/1778/1
line 35, org.eclipse.egit.ui.EclipseProxySelector.java: getURI() can return a null host name if the host name is undefined. We should defensively check for this. Bug: 325182 Change-Id: I85b02ba296f46ec71d167ba40b0c049fb0c96714 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java32
1 files changed, 17 insertions, 15 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java
index 9c9ce65..ccfbce2 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/EclipseProxySelector.java
@@ -34,22 +34,24 @@ class EclipseProxySelector extends ProxySelector {
final ArrayList<Proxy> r = new ArrayList<Proxy>();
final String host = uri.getHost();
- String type = IProxyData.SOCKS_PROXY_TYPE;
- if ("http".equals(uri.getScheme())) //$NON-NLS-1$
- type = IProxyData.HTTP_PROXY_TYPE;
- else if ("ftp".equals(uri.getScheme())) //$NON-NLS-1$
- type = IProxyData.HTTP_PROXY_TYPE;
- else if ("https".equals(uri.getScheme())) //$NON-NLS-1$
- type = IProxyData.HTTPS_PROXY_TYPE;
+ if (host != null) {
+ String type = IProxyData.SOCKS_PROXY_TYPE;
+ if ("http".equals(uri.getScheme())) //$NON-NLS-1$
+ type = IProxyData.HTTP_PROXY_TYPE;
+ else if ("ftp".equals(uri.getScheme())) //$NON-NLS-1$
+ type = IProxyData.HTTP_PROXY_TYPE;
+ else if ("https".equals(uri.getScheme())) //$NON-NLS-1$
+ type = IProxyData.HTTPS_PROXY_TYPE;
- final IProxyData data = service.getProxyDataForHost(host, type);
- if (data != null) {
- if (IProxyData.HTTP_PROXY_TYPE.equals(data.getType()))
- addProxy(r, Proxy.Type.HTTP, data);
- else if (IProxyData.HTTPS_PROXY_TYPE.equals(data.getType()))
- addProxy(r, Proxy.Type.HTTP, data);
- else if (IProxyData.SOCKS_PROXY_TYPE.equals(data.getType()))
- addProxy(r, Proxy.Type.SOCKS, data);
+ final IProxyData data = service.getProxyDataForHost(host, type);
+ if (data != null) {
+ if (IProxyData.HTTP_PROXY_TYPE.equals(data.getType()))
+ addProxy(r, Proxy.Type.HTTP, data);
+ else if (IProxyData.HTTPS_PROXY_TYPE.equals(data.getType()))
+ addProxy(r, Proxy.Type.HTTP, data);
+ else if (IProxyData.SOCKS_PROXY_TYPE.equals(data.getType()))
+ addProxy(r, Proxy.Type.SOCKS, data);
+ }
}
if (r.isEmpty())
r.add(Proxy.NO_PROXY);