Skip to content

Commit

Permalink
[ZEPPELIN-2152] Fix for npe in Helium loading when no proxies are set
Browse files Browse the repository at this point in the history
  • Loading branch information
necosta committed May 31, 2017
1 parent 8748005 commit cb25cd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Expand Up @@ -164,9 +164,10 @@ private ProxyConfig getProxyConfig(boolean isSecure) {
System.getenv("HTTPS_PROXY") : System.getenv("https_proxy");

try {
if (isSecure)
if (isSecure && StringUtils.isNotBlank(httpsProxy))
proxies.add(generateProxy("secure", new URI(httpsProxy)));
else proxies.add(generateProxy("insecure", new URI(httpProxy)));
else if (!isSecure && StringUtils.isNotBlank(httpProxy))
proxies.add(generateProxy("insecure", new URI(httpProxy)));
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
Expand Down
Expand Up @@ -31,7 +31,6 @@

import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -119,17 +118,18 @@ private HttpHost getProxy(String uri) {

try {
String scheme = new URI(uri).getScheme();
if (scheme.toLowerCase().startsWith("https")) {
if (scheme.toLowerCase().startsWith("https") && StringUtils.isNotBlank(httpsProxy)) {
URI httpsProxyUri = new URI(httpsProxy);
return new HttpHost(httpsProxyUri.getHost(),
httpsProxyUri.getPort(), httpsProxyUri.getScheme());
}
else {
else if (scheme.toLowerCase().startsWith("http") && StringUtils.isNotBlank(httpProxy)){
URI httpProxyUri = new URI(httpProxy);
return new HttpHost(httpProxyUri.getHost(),
httpProxyUri.getPort(), httpProxyUri.getScheme());
}
} catch (URISyntaxException ex) {
else return null;
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
return null;
}
Expand Down

0 comments on commit cb25cd7

Please sign in to comment.