diff --git a/client/src/main/java/com/metamx/druid/initialization/JettyServerModule.java b/client/src/main/java/com/metamx/druid/initialization/JettyServerModule.java index a1c83c33641..abbf3b091b5 100644 --- a/client/src/main/java/com/metamx/druid/initialization/JettyServerModule.java +++ b/client/src/main/java/com/metamx/druid/initialization/JettyServerModule.java @@ -2,12 +2,15 @@ package com.metamx.druid.initialization; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.Binder; +import com.google.inject.ConfigurationException; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provides; +import com.google.inject.ProvisionException; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.name.Named; @@ -110,7 +113,13 @@ public class JettyServerModule extends JerseyServletModule public Server getServer(Injector injector, Lifecycle lifecycle, ServerConfig config) { final Server server = Initialization.makeJettyServer(config); - initializer.initialize(server, injector); + try { + initializer.initialize(server, injector); + } + catch (ConfigurationException e) { + throw new ProvisionException(Iterables.getFirst(e.getErrorMessages(), null).getMessage()); + } + lifecycle.addHandler( new Lifecycle.Handler() diff --git a/server/src/main/java/com/metamx/druid/http/MasterMain.java b/server/src/main/java/com/metamx/druid/http/MasterMain.java index 4d8e45c18ef..a60b104e6d6 100644 --- a/server/src/main/java/com/metamx/druid/http/MasterMain.java +++ b/server/src/main/java/com/metamx/druid/http/MasterMain.java @@ -19,10 +19,7 @@ package com.metamx.druid.http; -import com.google.common.collect.Iterables; -import com.google.inject.ConfigurationException; import com.google.inject.Injector; -import com.google.inject.ProvisionException; import com.google.inject.servlet.GuiceFilter; import com.metamx.common.lifecycle.Lifecycle; import com.metamx.common.logger.Logger; @@ -98,25 +95,20 @@ public class MasterMain @Override public void initialize(Server server, Injector injector) { - try { - ResourceHandler resourceHandler = new ResourceHandler(); - resourceHandler.setResourceBase(MasterMain.class.getClassLoader().getResource("static").toExternalForm()); + ResourceHandler resourceHandler = new ResourceHandler(); + resourceHandler.setResourceBase(MasterMain.class.getClassLoader().getResource("static").toExternalForm()); - final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS); - root.setContextPath("/"); + final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS); + root.setContextPath("/"); - HandlerList handlerList = new HandlerList(); - handlerList.setHandlers(new Handler[]{resourceHandler, root, new DefaultHandler()}); - server.setHandler(handlerList); + HandlerList handlerList = new HandlerList(); + handlerList.setHandlers(new Handler[]{resourceHandler, root, new DefaultHandler()}); + server.setHandler(handlerList); - root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); - root.addFilter(GzipFilter.class, "/*", null); - root.addFilter(new FilterHolder(injector.getInstance(RedirectFilter.class)), "/*", null); - root.addFilter(GuiceFilter.class, "/*", null); - } - catch (ConfigurationException e) { - throw new ProvisionException(Iterables.getFirst(e.getErrorMessages(), null).getMessage()); - } + root.addServlet(new ServletHolder(new DefaultServlet()), "/*"); + root.addFilter(GzipFilter.class, "/*", null); + root.addFilter(new FilterHolder(injector.getInstance(RedirectFilter.class)), "/*", null); + root.addFilter(GuiceFilter.class, "/*", null); } } }