You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ve...@apache.org on 2016/04/19 02:31:45 UTC

drill git commit: DRILL-4390: Uses Resource where Drill favicon is located for static assets

Repository: drill
Updated Branches:
  refs/heads/master e4725ea53 -> 852b01aa6


DRILL-4390: Uses Resource where Drill favicon is located for static assets

Drill Webserver uses the first jar containing a rest/static directory to
find its static assets. In case of another jar containing this directory, it
might cause the webserver to return 404 errors.

This configures the server to use the resource containing the Drill favicon
as the place to look for all static resources.

this closes #378


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

Branch: refs/heads/master
Commit: 852b01aa63d03aa2fd4c0b73d5a3f267883b8d83
Parents: e4725ea
Author: Laurent Goujon <la...@dremio.com>
Authored: Tue Feb 16 16:47:17 2016 -0800
Committer: vkorukanti <ve...@dremio.com>
Committed: Mon Apr 18 16:59:33 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/drill/exec/server/rest/WebServer.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/852b01aa/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
index b4e25cb..5ea781b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/WebServer.java
@@ -105,6 +105,9 @@ public class WebServer implements AutoCloseable {
     }
   }
 
+  private static final String BASE_STATIC_PATH = "/rest/static/";
+  private static final String DRILL_ICON_RESOURCE_RELATIVE_PATH = "img/drill.ico";
+
   /**
    * Start the web server including setup.
    * @throws Exception
@@ -141,7 +144,12 @@ public class WebServer implements AutoCloseable {
     servletContextHandler.addServlet(new ServletHolder(new ThreadDumpServlet()), "/status/threads");
 
     final ServletHolder staticHolder = new ServletHolder("static", DefaultServlet.class);
-    staticHolder.setInitParameter("resourceBase", Resource.newClassPathResource("/rest/static").toString());
+    // Get resource URL for Drill static assets, based on where Drill icon is located
+    String drillIconResourcePath =
+        Resource.newClassPathResource(BASE_STATIC_PATH + DRILL_ICON_RESOURCE_RELATIVE_PATH).getURL().toString();
+    staticHolder.setInitParameter(
+        "resourceBase",
+        drillIconResourcePath.substring(0,  drillIconResourcePath.length() - DRILL_ICON_RESOURCE_RELATIVE_PATH.length()));
     staticHolder.setInitParameter("dirAllowed", "false");
     staticHolder.setInitParameter("pathInfoOnly", "true");
     servletContextHandler.addServlet(staticHolder, "/static/*");