Просмотр исходного кода

HADOOP-7448. Merge from yahoo-merge branch -r 1079157 and -r 1079164: HttpServer /stacks servlet should use plain text content type, without escaping. Contributed by Luke Lu.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1143613 13f79535-47bb-0310-9956-ffa450edef68
Matthew Foley 14 лет назад
Родитель
Сommit
d381ff25f4

+ 5 - 0
common/CHANGES.txt

@@ -358,6 +358,11 @@ Trunk (unreleased changes)
     HADOOP-7419. new hadoop-config.sh doesn't manage classpath for
     HADOOP_CONF_DIR correctly. (Bing Zheng and todd via todd)
 
+    HADOOP-7448. merge from yahoo-merge branch (via mattf):
+    -r 1079157: Fix content type for /stacks servlet to be 
+    plain text (Luke Lu)
+    -r 1079164: No need to escape plain text (Luke Lu)
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 2 - 3
common/src/java/org/apache/hadoop/http/HttpServer.java

@@ -411,7 +411,7 @@ public class HttpServer implements FilterContainer {
     for (Context ctx : defaultContexts.keySet()) {
       defineFilter(ctx, name, classname, parameters, ALL_URLS);
     }
-    LOG.info("Added global filter" + name + " (class=" + classname + ")");
+    LOG.info("Added global filter '" + name + "' (class=" + classname + ")");
   }
 
   /**
@@ -737,13 +737,12 @@ public class HttpServer implements FilterContainer {
     @Override
     public void doGet(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
-
+      response.setContentType("text/plain; charset=UTF-8");
       // Do the authorization
       if (!HttpServer.hasAdministratorAccess(getServletContext(), request,
           response)) {
         return;
       }
-
       PrintWriter out = response.getWriter();
       ReflectionUtils.printThreadInfo(out, "");
       out.close();

+ 2 - 3
common/src/test/core/org/apache/hadoop/http/TestHttpServer.java

@@ -61,6 +61,7 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 public class TestHttpServer extends HttpServerFunctionalTest {
+  static final Log LOG = LogFactory.getLog(TestHttpServer.class);
   private static HttpServer server;
   private static URL baseUrl;
   private static final int MAX_THREADS = 10;
@@ -136,6 +137,7 @@ public class TestHttpServer extends HttpServerFunctionalTest {
     server.addServlet("htmlcontent", "/htmlcontent", HtmlContentServlet.class);
     server.start();
     baseUrl = getServerURL(server);
+    LOG.info("HTTP server started: "+ baseUrl);
   }
   
   @AfterClass public static void cleanup() throws Exception {
@@ -233,9 +235,6 @@ public class TestHttpServer extends HttpServerFunctionalTest {
    * 
    */
   public static class DummyServletFilter implements Filter {
-
-    private static final Log LOG = LogFactory.getLog(
-        DummyServletFilter.class);
     @Override
     public void destroy() { }