diff options
| author | Scott Michel | 2010-10-21 13:46:04 +0000 |
|---|---|---|
| committer | Matthias Sohn | 2010-10-21 13:46:04 +0000 |
| commit | c0636b5c957ae520799f9b073da16f5455ad539e (patch) | |
| tree | 661985a17ae0200a0b61d3baf2a60a664993bd97 | |
| parent | d2d3e078d3f18e35ecf4bcf077e039fc207af488 (diff) | |
| download | egit-c0636b5c957ae520799f9b073da16f5455ad539e.tar.gz egit-c0636b5c957ae520799f9b073da16f5455ad539e.tar.xz egit-c0636b5c957ae520799f9b073da16f5455ad539e.zip | |
Fix potential NPE in EclipseProxySelector
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.java | 32 |
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 9c9ce654e3..ccfbce20e5 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); |
