From 598eaad7e1ceac983ac0fef7766d0455f57eda82 Mon Sep 17 00:00:00 2001 From: Rishabh Singh <6513075+findingrish@users.noreply.github.com> Date: Sat, 25 Mar 2023 14:01:09 +0530 Subject: [PATCH] Fix HSTS for middle manager (#13975) Fix HSTS for middle manager --- .../MiddleManagerJettyServerInitializer.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/services/src/main/java/org/apache/druid/cli/MiddleManagerJettyServerInitializer.java b/services/src/main/java/org/apache/druid/cli/MiddleManagerJettyServerInitializer.java index a4e0b0bb66e..4aa44ee0493 100644 --- a/services/src/main/java/org/apache/druid/cli/MiddleManagerJettyServerInitializer.java +++ b/services/src/main/java/org/apache/druid/cli/MiddleManagerJettyServerInitializer.java @@ -33,7 +33,6 @@ import org.apache.druid.server.security.AuthConfig; import org.apache.druid.server.security.AuthenticationUtils; import org.apache.druid.server.security.Authenticator; import org.apache.druid.server.security.AuthenticatorMapper; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; @@ -97,18 +96,18 @@ class MiddleManagerJettyServerInitializer implements JettyServerInitializer root.addFilter(GuiceFilter.class, "/*", null); final HandlerList handlerList = new HandlerList(); - handlerList.setHandlers( - new Handler[]{ - JettyServerInitUtils.getJettyRequestLogHandler(), - JettyServerInitUtils.wrapWithDefaultGzipHandler( - root, - serverConfig.getInflateBufferSize(), - serverConfig.getCompressionLevel() - ), - new DefaultHandler() - } - ); JettyServerInitUtils.maybeAddHSTSRewriteHandler(serverConfig, handlerList); + + handlerList.addHandler(JettyServerInitUtils.getJettyRequestLogHandler()); + + handlerList.addHandler(JettyServerInitUtils.wrapWithDefaultGzipHandler( + root, + serverConfig.getInflateBufferSize(), + serverConfig.getCompressionLevel() + )); + + handlerList.addHandler(new DefaultHandler()); + server.setHandler(handlerList); } }