You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2017/05/31 18:18:10 UTC

zeppelin git commit: [ZEPPELIN-2152] Fix for npe in Helium loading when no proxies are set

Repository: zeppelin
Updated Branches:
  refs/heads/master 87480056a -> 88c5c3ccd


[ZEPPELIN-2152] Fix for npe in Helium loading when no proxies are set

### What is this PR for?
Emergency fix for npe when calling Helium and with no proxies env variables set.

### What type of PR is it?
Bug Fix

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-2152

### How should this be tested?
* clone new zeppelin repository
* unset http_proxy/https_proxy env variables (if set)
* build ` mvn clean package -DskipTests;`
* start zeppelin instance

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Nelson Costa <ne...@gmail.com>

Closes #2380 from necosta/zeppelin2152-patch and squashes the following commits:

cb25cd7 [Nelson Costa] [ZEPPELIN-2152] Fix for npe in Helium loading when no proxies are set


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/88c5c3cc
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/88c5c3cc
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/88c5c3cc

Branch: refs/heads/master
Commit: 88c5c3ccd9e346d48637d3c63c8dff5ba53c8d8e
Parents: 8748005
Author: Nelson Costa <ne...@gmail.com>
Authored: Wed May 31 12:20:27 2017 +0100
Committer: Lee moon soo <mo...@apache.org>
Committed: Wed May 31 11:18:05 2017 -0700

----------------------------------------------------------------------
 .../java/org/apache/zeppelin/helium/HeliumBundleFactory.java | 5 +++--
 .../org/apache/zeppelin/helium/HeliumOnlineRegistry.java     | 8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/88c5c3cc/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java
index c585567..52e4f6d 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java
@@ -164,9 +164,10 @@ public class HeliumBundleFactory {
             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);
     }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/88c5c3cc/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java
index 165d70a..1ea1982 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java
@@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.*;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -119,17 +118,18 @@ public class HeliumOnlineRegistry extends HeliumRegistry {
 
     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;
     }