HADOOP-10748. HttpServer2 should not load JspServlet. Contributed by Haohui Mai.

This commit is contained in:
Haohui Mai 2014-08-27 13:26:25 -07:00
parent caaf778768
commit 3476b9630f
2 changed files with 14 additions and 0 deletions

View File

@ -14,6 +14,8 @@ Release 2.7.0 - UNRELEASED
HADOOP-11172. Improve error message in Shell#runCommand on OutOfMemoryError.
(Yongjun Zhang via wang)
HADOOP-10748. HttpServer2 should not load JspServlet. (wheat9)
OPTIMIZATIONS
BUG FIXES

View File

@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.HadoopIllegalArgumentException;
@ -415,6 +416,17 @@ public final class HttpServer2 implements FilterContainer {
private static WebAppContext createWebAppContext(String name,
Configuration conf, AccessControlList adminsAcl, final String appDir) {
WebAppContext ctx = new WebAppContext();
ctx.setDefaultsDescriptor(null);
ServletHolder holder = new ServletHolder(new DefaultServlet());
Map<String, String> params = ImmutableMap. <String, String> builder()
.put("acceptRanges", "true")
.put("dirAllowed", "false")
.put("gzip", "true")
.put("useFileMappedBuffer", "true")
.build();
holder.setInitParameters(params);
ctx.setWelcomeFiles(new String[] {"index.html"});
ctx.addServlet(holder, "/");
ctx.setDisplayName(name);
ctx.setContextPath("/");
ctx.setWar(appDir + "/" + name);