knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [08/25] knox git commit: KNOX-1049 - check for null topology to avoid NPE in tests
Date Thu, 02 Nov 2017 18:48:12 GMT
KNOX-1049 - check for null topology to avoid NPE in tests

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

Branch: refs/heads/KNOX-998-Package_Restructuring
Commit: c211d05e98c82d57eb0af61487a76f0ddd99660d
Parents: 1ee9370
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Thu Oct 26 11:17:30 2017 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Thu Oct 26 11:17:30 2017 -0400

----------------------------------------------------------------------
 .../apache/hadoop/gateway/GatewayFilter.java    | 41 ++++++++++----------
 1 file changed, 21 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/c211d05e/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
index 2885fe3..7617ae8 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
@@ -128,28 +128,29 @@ public class GatewayFilter implements Filter {
     // if there was no match then look for a default service for the topology
     if (match == null) {
       Topology topology = (Topology) servletRequest.getServletContext().getAttribute("org.apache.hadoop.gateway.topology");
-      String defaultServicePath = topology.getDefaultServicePath();
-      if (defaultServicePath != null) {
-        try {
-          String newPathWithQuery = defaultServicePath + "/" + pathWithQueryTemplate;
-          match = chains.match(Parser.parseLiteral(newPathWithQuery));
-          String origUrl = ((HttpServletRequest) servletRequest).getRequestURL().toString();
-          String url = origUrl;
-          if (path.equals("/")) {
-            url += defaultServicePath;
-          }
-          else {
-            int index = origUrl.indexOf(path);
-            url = origUrl.substring(0, index) + "/" + defaultServicePath + path;
+      if (topology != null) {
+        String defaultServicePath = topology.getDefaultServicePath();
+        if (defaultServicePath != null) {
+          try {
+            String newPathWithQuery = defaultServicePath + "/" + pathWithQueryTemplate;
+            match = chains.match(Parser.parseLiteral(newPathWithQuery));
+            String origUrl = ((HttpServletRequest) servletRequest).getRequestURL().toString();
+            String url = origUrl;
+            if (path.equals("/")) {
+              url += defaultServicePath;
+            }
+            else {
+              int index = origUrl.indexOf(path);
+              url = origUrl.substring(0, index) + "/" + defaultServicePath + path;
+            }
+            String contextPath = defaultServicePath;
+            servletRequest = new ForwardedRequest((HttpServletRequest) servletRequest, 
+                contextPath, 
+                url);
+          } catch (URISyntaxException e) {
+            throw new ServletException( e );
           }
-          String contextPath = defaultServicePath;
-          servletRequest = new ForwardedRequest((HttpServletRequest) servletRequest, 
-              contextPath, 
-              url);
-        } catch (URISyntaxException e) {
-          throw new ServletException( e );
         }
-//        ((HttpServletRequest) servletRequest).getRequestURL();
       }
     }
 


Mime
View raw message